Message301985
> 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. |
|
Date |
User |
Action |
Args |
2017-09-12 17:59:22 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, barry, rhettinger, pitrou, benjamin.peterson, hodgestar, Arfrever, lukasz.langa, python-dev, eric.snow, robagar |
2017-09-12 17:59:22 | serhiy.storchaka | set | messageid: <1505239162.26.0.0885419599423.issue16251@psf.upfronthosting.co.za> |
2017-09-12 17:59:22 | serhiy.storchaka | link | issue16251 messages |
2017-09-12 17:59:22 | serhiy.storchaka | create | |
|