-
- Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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 linux Type "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 linux Type "help", "copyright", "credits" or "license" for more information. >>> from pickle import Unpickler >>> a=Unpickler(open('/dev/zero')) >>> a.persistent_load=lambda x: x Traceback (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-only I 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 linux Type "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
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done