[issue1581183] pickle protocol 2 failure on int subclass
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: -- status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I am going to close this as a duplicate of issue 1062277. The later has a patch, but Raymond questioned whether proposed feature is desirable. [msg47268] I am -1, but will look at the patch there. -- nosy: +rhettinger resolution: - duplicate status: open - pending superseder: - Pickle breakage with reduction of recursive structures ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: -- components: +Documentation ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: At least part of the problem has nothing to do with subclassing from int and instead is related to pickling objects with circular references. I am attaching a patch that demonstrates the problem. In issue1581183-test.diff, I modified memoize so that it does nothing rather than fails an assert if object is already in the memo. This makes python and C implementations behave the same, but still fail to produce correct results. Pickling with protocol 2 break circular reference and instead creates two independent objects. -- assignee: - belopolsky keywords: +patch Added file: http://bugs.python.org/file17800/issue1581183-test.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Removed file: http://bugs.python.org/file17800/issue1581183-test.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Added file: http://bugs.python.org/file17801/issue1581183-test.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Upon further investigation, I conclude that the problem is in the user code. I am attaching int_subclass_pickle_problem_fixed.py which fixes the user code as follows: def __getnewargs__(self): -return (int(self), self.an_enum) +return (int(self), None) Note that with this change, the object is pickled correctly because __setstate__ takes care of resetting self.an_enum. The problem is that self-referential state should not be passed via __getnewargs__ mechanism. This is because when pickler starts writing newargs, it is already committed to creating a new object (otherwise it would not need to serialize newargs in the first place.) If the newargs contain the object that is being pickled, it will be serialized twice unless this situation is caught in memoize. What can be improved, is the diagnostic and possibly documentation. If after saving newargs, memo contains the object that is being pickled, an exception should be raised explaining that __getnewargs__() should not contain self-references. -- keywords: -patch priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I reproduced the problem in py3k (both protocol 2 and 3). See issue1581183-test-py3k.py attached. -- nosy: +alexandre.vassalotti, belopolsky versions: +Python 3.2 Added file: http://bugs.python.org/file17798/issue1581183-test-py3k.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1581183] pickle protocol 2 failure on int subclass
Daniel Diniz aja...@gmail.com added the comment: Confirmed on trunk, has tests. -- nosy: +ajaksu2 stage: - needs patch title: pickle protocol 2 failure on int subclass - pickle protocol 2 failure on int subclass type: - behavior versions: +Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1581183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com