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, pitrou, serhiy.storchaka
Date 2014-12-04.13:16:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1417699003.47.0.104663960497.issue22995@psf.upfronthosting.co.za>
In-reply-to
Content
When no efforts were spent to support pickling of instances of Python class, in most cases the class will be pickleable. Default implementation just saves all attributes and this works if all attributes are pickleable. Exceptional special cases:

1) Classes with __slot__. In this case an attempt to pickle will raise an exception with explaining message.

2) Classes with __new__ wish mandatory parameters. In this case the pickling will be silently "successful", but actually data will be not saved and unpickling will fail. See for example issue21975, issue22955.

But when the class is implemented in C and doesn't expose its attribute in __dict__, in most cases it is variant (2) -- silent incorrect pickling.

I think we should prevent incorrect pickling by default. It is better to fail loudly. Default reduce could inspect the __new__ method and raise an exception if it has non-optional parameters and the class doesn't implement __getnewargs_ex__ or __getnewargs__ methods. And fail on all classes implemented in C if they don't implement any pickle-related methods.
History
Date User Action Args
2014-12-04 13:16:43serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, alexandre.vassalotti
2014-12-04 13:16:43serhiy.storchakasetmessageid: <1417699003.47.0.104663960497.issue22995@psf.upfronthosting.co.za>
2014-12-04 13:16:43serhiy.storchakalinkissue22995 messages
2014-12-04 13:16:42serhiy.storchakacreate