mirror of
https://github.com/django/django.git
synced 2025-07-05 10:19:20 +00:00
[1.1.X] Fixed #12121 -- Modified __reduce__ on a model to avoid an infinite recursion problem that occurs on Python 2.4. Thanks to emulbreh for the report.
Backport of r11691 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11692 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9e02b4a0e1
commit
fe9a45e514
@ -359,10 +359,15 @@ class Model(object):
|
|||||||
only module-level classes can be pickled by the default path.
|
only module-level classes can be pickled by the default path.
|
||||||
"""
|
"""
|
||||||
data = self.__dict__
|
data = self.__dict__
|
||||||
if not self._deferred:
|
model = self.__class__
|
||||||
return super(Model, self).__reduce__()
|
# The obvious thing to do here is to invoke super().__reduce__()
|
||||||
|
# for the non-deferred case. Don't do that.
|
||||||
|
# On Python 2.4, there is something wierd with __reduce__,
|
||||||
|
# and as a result, the super call will cause an infinite recursion.
|
||||||
|
# See #10547 and #12121.
|
||||||
defers = []
|
defers = []
|
||||||
pk_val = None
|
pk_val = None
|
||||||
|
if self._deferred:
|
||||||
for field in self._meta.fields:
|
for field in self._meta.fields:
|
||||||
if isinstance(self.__class__.__dict__.get(field.attname),
|
if isinstance(self.__class__.__dict__.get(field.attname),
|
||||||
DeferredAttribute):
|
DeferredAttribute):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user