1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

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

Forwardport of 30f334cc58 from stable/1.11.x
This commit is contained in:
Sergey Fedoseev 2017-07-12 15:18:49 +05:00 committed by Tim Graham
parent 59a4b12a23
commit 83440a1258
2 changed files with 5 additions and 0 deletions

View File

@ -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`).

View File

@ -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