Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
In Python releases previous to 3.13, the following code used to work (this idiom is used in Durus and ZODB persistence systems):
Python 3.12.7 (main, Oct 3 2024, 03:21:52) [GCC 10.5.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from pickle import Unpickler>>> a=Unpickler(open('/dev/zero')) >>> a.persistent_load=lambda x: x>>>Fine so far.
In Python 3.13, this doesn't work anymore:
Python 3.13.0 (main, Oct 9 2024, 14:54:06) [GCC 10.5.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from pickle import Unpickler>>> a=Unpickler(open('/dev/zero'))>>> a.persistent_load=lambda x: xTraceback (most recent call last): File "<python-input-2>", line 1, in <module> a.persistent_load=lambda x: x ^^^^^^^^^^^^^^^^^AttributeError: '_pickle.Unpickler' object attribute 'persistent_load' is read-onlyI don't know if this is an intended change or a regression.
PS: The subclass approach works:
Python 3.13.0 (main, Oct 9 2024, 14:54:06) [GCC 10.5.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from pickle import Unpickler>>> def x(Unpickler):... def persistent_load(self, x):... return x... >>> b=x(open("/dev/zero"))>>>CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done