Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Properly support pickling of LazyObjects in Python 3.3

  • Loading branch information...
1 parent bdcd2f6 commit 3266c26eb22599a5577d41856baa04e99f87efe4 @clelland clelland committed with spookylukey
Showing with 10 additions and 0 deletions.
  1. +10 −0 django/utils/
10 django/utils/
@@ -293,6 +293,16 @@ def __getstate__(self):
return self._wrapped.__dict__
+ # Python 3.3 will call __reduce__ when pickling; these methods are needed
+ # to serialize and deserialize correctly. They are not called in earlier
+ # versions of Python.
+ @classmethod
+ def __newobj__(cls, *args):
+ return cls.__new__(cls, *args)
+ def __reduce__(self):
+ return (self.__newobj__, (self.__class__,), self.__getstate__())
# Need to pretend to be the wrapped class, for the sake of objects that care
# about this (especially in equality tests)
__class__ = property(new_method_proxy(operator.attrgetter("__class__")))

0 comments on commit 3266c26

Please sign in to comment.
Something went wrong with that request. Please try again.