Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28389 closed Bug (fixed)

Regression in pickling LazyObject on Python 2 if wrapped object doesn't have __reduce__()

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: Utilities Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In [126]: import pickle
In [127]: from django.utils.functional import LazyObject
In [128]: class A(object):
     ...:     pass
     ...:
In [129]: lazy_obj = LazyObject()
In [130]: a = A()
In [131]: a.foo = 'bar'
In [132]: lazy_obj._wrapped = a
In [133]: pickle.loads(pickle.dumps(lazy_obj)).foo
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-133-a85d49df8170> in <module>()
----> 1 pickle.loads(pickle.dumps(lazy_obj)).foo

AttributeError: 'A' object has no attribute 'foo'

Introduced in 35355a4ffedb2aeed52d5fe3034380ffc6a438db.

Change History (5)

comment:1 by Sergey Fedoseev, 7 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Sergey Fedoseev, 7 years ago

Has patch: set

comment:3 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 30f334c:

[1.11.x] Fixed #28389 -- Fixed pickling of LazyObject on Python 2 when wrapped object doesn't have reduce().

Partial revert of 35355a4ffedb2aeed52d5fe3034380ffc6a438db.

comment:4 by Tim Graham, 7 years ago

Summary: pickling LazyObject works incorrectly on Python 2Regression in pickling LazyObject on Python 2 if wrapped object doesn't have __reduce__()
Triage Stage: UnreviewedReady for checkin

comment:5 by Tim Graham <timograham@…>, 7 years ago

In 83440a1:

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

Note: See TracTickets for help on using tickets.
Back to Top