Loading django/core/cache/backends/filebased.py +2 −2 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ class FileBasedCache(BaseCache): try: with io.open(fd, 'wb') as f: expiry = self.get_backend_timeout(timeout) f.write(pickle.dumps(expiry, -1)) f.write(zlib.compress(pickle.dumps(value), -1)) f.write(pickle.dumps(expiry, pickle.HIGHEST_PROTOCOL)) f.write(zlib.compress(pickle.dumps(value, pickle.HIGHEST_PROTOCOL), -1)) file_move_safe(tmp_path, fname, allow_overwrite=True) renamed = True finally: Loading docs/releases/1.10.txt +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ Minor features Cache ^^^^^ * ... * The file-based cache backend now uses the highest pickling protocol. CSRF ^^^^ Loading tests/cache/tests.py +9 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,11 @@ class Unpickable(object): raise pickle.PickleError() class UnpicklableType(object): # Unpicklable using the default pickling protocol on Python 2. __slots__ = 'a', @override_settings(CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', Loading Loading @@ -1221,6 +1226,10 @@ class FileBasedCacheTests(BaseCacheTests, TestCase): cache.set('foo', 'bar') os.path.exists(self.dirname) def test_cache_write_unpickable_type(self): # This fails if not using the highest pickling protocol on Python 2. cache.set('unpickable', UnpicklableType()) @override_settings(CACHES={ 'default': { Loading Loading
django/core/cache/backends/filebased.py +2 −2 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ class FileBasedCache(BaseCache): try: with io.open(fd, 'wb') as f: expiry = self.get_backend_timeout(timeout) f.write(pickle.dumps(expiry, -1)) f.write(zlib.compress(pickle.dumps(value), -1)) f.write(pickle.dumps(expiry, pickle.HIGHEST_PROTOCOL)) f.write(zlib.compress(pickle.dumps(value, pickle.HIGHEST_PROTOCOL), -1)) file_move_safe(tmp_path, fname, allow_overwrite=True) renamed = True finally: Loading
docs/releases/1.10.txt +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ Minor features Cache ^^^^^ * ... * The file-based cache backend now uses the highest pickling protocol. CSRF ^^^^ Loading
tests/cache/tests.py +9 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,11 @@ class Unpickable(object): raise pickle.PickleError() class UnpicklableType(object): # Unpicklable using the default pickling protocol on Python 2. __slots__ = 'a', @override_settings(CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', Loading Loading @@ -1221,6 +1226,10 @@ class FileBasedCacheTests(BaseCacheTests, TestCase): cache.set('foo', 'bar') os.path.exists(self.dirname) def test_cache_write_unpickable_type(self): # This fails if not using the highest pickling protocol on Python 2. cache.set('unpickable', UnpicklableType()) @override_settings(CACHES={ 'default': { Loading