From 83440a1258ab2e0c29ce2c5d3586456ece20b633 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Wed, 12 Jul 2017 15:18:49 +0500 Subject: [PATCH] Refs #28389 -- Added release note and test for pickling of LazyObject when wrapped object doesn't have __reduce__(). Forwardport of 30f334cc58e939c7d9bd8455c80bd066fbde9f2b from stable/1.11.x --- docs/releases/1.11.4.txt | 3 +++ tests/utils_tests/test_lazyobject.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/docs/releases/1.11.4.txt b/docs/releases/1.11.4.txt index 2383ad6a176..2cd093335e8 100644 --- a/docs/releases/1.11.4.txt +++ b/docs/releases/1.11.4.txt @@ -15,3 +15,6 @@ Bugfixes * Fixed ``QuerySet.union()`` and ``difference()`` when combining with a queryset raising ``EmptyResultSet`` (:ticket:`28378`). + +* Fixed a regression in pickling of ``LazyObject`` on Python 2 when the wrapped + object doesn't have ``__reduce__()`` (:ticket:`28389`). diff --git a/tests/utils_tests/test_lazyobject.py b/tests/utils_tests/test_lazyobject.py index 4a4e929cda7..2bba558843d 100644 --- a/tests/utils_tests/test_lazyobject.py +++ b/tests/utils_tests/test_lazyobject.py @@ -184,11 +184,13 @@ class LazyObjectTestCase(TestCase): def test_pickle(self): # See ticket #16563 obj = self.lazy_wrap(Foo()) + obj.bar = 'baz' pickled = pickle.dumps(obj) unpickled = pickle.loads(pickled) self.assertIsInstance(unpickled, Foo) self.assertEqual(unpickled, obj) self.assertEqual(unpickled.foo, obj.foo) + self.assertEqual(unpickled.bar, obj.bar) # Test copying lazy objects wrapping both builtin types and user-defined # classes since a lot of the relevant code does __dict__ manipulation and