Serhiy Storchaka added the comment:
> The two test cases added demonstrate what was impossible to pickle before and
> is now.
These two classes obviously are not pickleable. Pickling or copying them is a
programming error. I believe the proper way of making them pickleable and
copyable is implementing corresponding special methods.
> Can you give me an example where this would lead to incorrect pickle data?
Any class that needs non-trivial __getstate__(). If pickling is failed now it
means that the class is not pickleable. With your patch pickling can be
successful, but there is no guarantee that it is correct.
For example, modifying one of your example:
class Proxy:
def __init__(self, proxied_object):
self.proxied_object = proxied_object
self.id = id(proxied_object)
def __getattr__(self, name):
return getattr(self.proxied_object, name)
> This is what `hasattr()` in Python 2 did. This is why in Python 2 the
> `RecursionError` example I added to the tests was actually working just fine.
hasattr() is broken in Python 2. It was fixed in Python 3. Your patch
reintroduces similar bug in copy.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue16251>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com