This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients alexandre.vassalotti, phd, pitrou, serhiy.storchaka
Date 2015-11-28.14:11:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448719910.65.0.878452508786.issue18068@psf.upfronthosting.co.za>
In-reply-to
Content
The weakref.proxy object delegates all attribute access to referred object, including special attributes used in pickling, like __class__ or __getstate__.

test.recursive is not test, but it looks as TestPickle instance for the pickler. It is pickled and unpickled as TestPickle instance.

>>> test.recursive.__class__
<class '__main__.TestPickle'>
>>> test.recursive.__getstate__
<bound method TestPickle.__getstate__ of <__main__.TestPickle object at 0xb7130bac>>
>>> test.recursive.__reduce_ex__(2)
__getstate__ 3071478700
(<function __newobj__ at 0xb74b76f4>, (<class '__main__.TestPickle'>,), {'recursive': <weakproxy at 0xb7127a04 to TestPickle at 0xb7130bac>}, None, None)
>>> pickle.loads(pickle.dumps(test.recursive, 2))
__getstate__ 3071478700
__setstate__ 3071525356
<__main__.TestPickle object at 0xb713c1ec>

Since test.recursive.recursive is test.recursive, this recursion is detected by pickler.

This issue is similar to issue6395, but since weakref.proxy is not subclassable, we can just implement correct __reduce__.
History
Date User Action Args
2015-11-28 14:11:50serhiy.storchakasetrecipients: + serhiy.storchaka, phd, pitrou, alexandre.vassalotti
2015-11-28 14:11:50serhiy.storchakasetmessageid: <1448719910.65.0.878452508786.issue18068@psf.upfronthosting.co.za>
2015-11-28 14:11:50serhiy.storchakalinkissue18068 messages
2015-11-28 14:11:50serhiy.storchakacreate