diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 8272e246c6..8c3226ff48 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -536,6 +536,18 @@ For apps with migrations, ``allow_migrate`` will now get passed without custom attributes, methods or managers. Make sure your ``allow_migrate`` methods are only referring to fields or other items in ``model._meta``. +Behavior of ``LocMemCache`` regarding pickle errors +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +An inconsistency existed in previous versions of Django regarding how pickle +errors are handled by different cache backends. +``django.core.cache.backends.locmem.LocMemCache`` used to fail silently when +such an error occurs, which is inconsistent with other backends and leads to +cache-specific errors. This has been fixed in Django 1.7, see +`Ticket #21200`_ for more details. + +.. _Ticket #21200: https://code.djangoproject.com/ticket/21200 + Passing ``None`` to ``Manager.db_manager()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 0e512a6a41..b03c3494fc 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -48,6 +48,11 @@ class C: return 24 +class Unpickable(object): + def __getstate__(self): + raise pickle.PickleError() + + @override_settings(CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', @@ -847,6 +852,16 @@ class BaseCacheTests(object): self.assertEqual(get_cache_data.content, content.encode('utf-8')) self.assertEqual(get_cache_data.cookies, response.cookies) + def test_add_fail_on_pickleerror(self): + "See https://code.djangoproject.com/ticket/21200" + with self.assertRaises(pickle.PickleError): + cache.add('unpickable', Unpickable()) + + def test_set_fail_on_pickleerror(self): + "See https://code.djangoproject.com/ticket/21200" + with self.assertRaises(pickle.PickleError): + cache.set('unpickable', Unpickable()) + @override_settings(CACHES=caches_setting_for_tests( BACKEND='django.core.cache.backends.db.DatabaseCache',