-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"pickle.Unpickler.persistent_load" and "pickle.Pickler.persistent_id" became read-only in python 3.13 #125631
Comments
The same issue happens with
Good so far. But in Python 3.13.0:
|
@serhiy-storchaka, Could you possibly verify this? Thanks. |
…pickler and unpickler pickle.Pickler and pickle.Unpickler instances have now managed dicts. Arbitrary instance attributes, including persistent_id and persistent_load, can now be set.
Yes, this is a consequence of the #89850 change. I missed such use case because there were no tests for it. You still can override attributes of instances of subclasses. The proposed fix adds managed dicts to these classes (I would add simple instance dicts, but it is easier to add managed dicts). This may open a can of worms, because you can now set arbitrary attributes of instances of these classes. There will be no way to close it. But I think this is the only way to make this working while keeping |
What about restoring the property support (get/set) for those two attributes? It could even support "delete" to reactivate current configuration, although I don't think that anybody overwriting "persistent_id" or "persistent_load" would be interested in that. |
…pickler and unpickler pickle.Pickler.persistent_id and pickle.Unpickler.persistent_load can again be overridden as instance attributes.
This would be very complex solution and it would not work with But we can make attributes (and only these attributes) writable by implementing |
…r and unpickler (GH-125752) pickle.Pickler.persistent_id and pickle.Unpickler.persistent_load can again be overridden as instance attributes.
…pickler and unpickler (pythonGH-125752) pickle.Pickler.persistent_id and pickle.Unpickler.persistent_load can again be overridden as instance attributes. (cherry picked from commit 223d3dc) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…pickler and unpickler (pythonGH-125752) pickle.Pickler.persistent_id and pickle.Unpickler.persistent_load can again be overridden as instance attributes.
Does this problem have a fix ? I am facing the same issues |
It was solved in Python 3.13.1, already a couple of weeks old. |
…pickler and unpickler (pythonGH-125752) pickle.Pickler.persistent_id and pickle.Unpickler.persistent_load can again be overridden as instance attributes.
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):
Fine so far.
In Python 3.13, this doesn't work anymore:
I don't know if this is an intended change or a regression.
PS: The subclass approach works:
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: