Kaydet (Commit) 83440a12 authored tarafından Sergey Fedoseev's avatar Sergey Fedoseev Kaydeden (comit) Tim Graham

Refs #28389 -- Added release note and test for pickling of LazyObject when…

Refs #28389 -- Added release note and test for pickling of LazyObject when wrapped object doesn't have __reduce__().

Forwardport of 30f334cc from stable/1.11.x
üst 59a4b12a
...@@ -15,3 +15,6 @@ Bugfixes ...@@ -15,3 +15,6 @@ Bugfixes
* Fixed ``QuerySet.union()`` and ``difference()`` when combining with * Fixed ``QuerySet.union()`` and ``difference()`` when combining with
a queryset raising ``EmptyResultSet`` (:ticket:`28378`). 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`).
...@@ -184,11 +184,13 @@ class LazyObjectTestCase(TestCase): ...@@ -184,11 +184,13 @@ class LazyObjectTestCase(TestCase):
def test_pickle(self): def test_pickle(self):
# See ticket #16563 # See ticket #16563
obj = self.lazy_wrap(Foo()) obj = self.lazy_wrap(Foo())
obj.bar = 'baz'
pickled = pickle.dumps(obj) pickled = pickle.dumps(obj)
unpickled = pickle.loads(pickled) unpickled = pickle.loads(pickled)
self.assertIsInstance(unpickled, Foo) self.assertIsInstance(unpickled, Foo)
self.assertEqual(unpickled, obj) self.assertEqual(unpickled, obj)
self.assertEqual(unpickled.foo, obj.foo) self.assertEqual(unpickled.foo, obj.foo)
self.assertEqual(unpickled.bar, obj.bar)
# Test copying lazy objects wrapping both builtin types and user-defined # Test copying lazy objects wrapping both builtin types and user-defined
# classes since a lot of the relevant code does __dict__ manipulation and # classes since a lot of the relevant code does __dict__ manipulation and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment