Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"pickle.Unpickler.persistent_load" and "pickle.Pickler.persistent_id" became read-only in python 3.13 #125631

Closed
Assignees
serhiy-storchaka
Labels
3.13bugs and security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error
@jcea

Description

@jcea

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-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 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

Labels

3.13bugs and security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp