Commit 08d521ef authored by Russell Keith-Magee's avatar Russell Keith-Magee
Browse files

Fixed #12121 -- Modified __reduce__ on a model to avoid an infinite recursion...

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.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11691 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 8dd4a287
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -352,10 +352,15 @@ class Model(object):
        only module-level classes can be pickled by the default path.
        """
        data = self.__dict__
        if not self._deferred:
            return super(Model, self).__reduce__()
        model = self.__class__
        # 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 = []
        pk_val = None
        if self._deferred:
            for field in self._meta.fields:
                if isinstance(self.__class__.__dict__.get(field.attname),
                        DeferredAttribute):