diff --git a/django/core/cache/backends/locmem.py b/django/core/cache/backends/locmem.py
index 9196b3b..0054d22 100644
a
|
b
|
class LocMemCache(BaseCache):
|
69 | 69 | def set(self, key, value, timeout=None, version=None): |
70 | 70 | key = self.make_key(key, version=version) |
71 | 71 | self.validate_key(key) |
| 72 | try: |
| 73 | pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL) |
| 74 | except pickle.PickleError: |
| 75 | return |
72 | 76 | with self._lock.writer(): |
73 | | try: |
74 | | pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL) |
75 | | self._set(key, pickled, timeout) |
76 | | except pickle.PickleError: |
77 | | pass |
| 77 | self._set(key, pickled, timeout) |
78 | 78 | |
79 | 79 | def incr(self, key, delta=1, version=None): |
80 | 80 | value = self.get(key, version=version) |
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index 264ef74..dca7d00 100644
a
|
b
|
class C:
|
42 | 42 | return 24 |
43 | 43 | |
44 | 44 | |
| 45 | class PicklingSideEffect(object): |
| 46 | def __getstate__(self): |
| 47 | self.cache.get('foo') |
| 48 | return {} |
| 49 | |
| 50 | |
45 | 51 | class DummyCacheTests(unittest.TestCase): |
46 | 52 | # The Dummy cache backend doesn't really behave like a test backend, |
47 | 53 | # so it has different test requirements. |
… |
… |
class LocMemCacheTests(unittest.TestCase, BaseCacheTests):
|
919 | 925 | self.assertEqual(mirror_cache.get('value1'), 42) |
920 | 926 | self.assertEqual(other_cache.get('value1'), None) |
921 | 927 | |
| 928 | def test_locking_on_pickle(self): |
| 929 | |
| 930 | cache = self.cache |
| 931 | |
| 932 | bad_obj = PicklingSideEffect() |
| 933 | bad_obj.cache = cache |
| 934 | cache.set('bar', bad_obj) |
| 935 | |
922 | 936 | def test_incr_decr_timeout(self): |
923 | 937 | """incr/decr does not modify expiry time (matches memcached behavior)""" |
924 | 938 | key = 'value' |