-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
[3.13] copyreg._reconstructor crashes when trying to pickle.load specific serialized data #135201
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
Comments
Hi, I suspect this is related to a library you're using. The repro fails with this:
I doubt |
Yeah, it is: I fixed it at the level of copyreg, finding information that this way of using the With the above fix the result of a pickle.load() is this:
Strangely enough it doesn't contain anything outside of the standard library. I'm looking at a diff between the culprit file and a dump of the above data, and what immediately stands out is that diff -u 74b9da0a-ab54-437f-9ab5-549e886d3c83.txt tmp.pickle | head
--- 74b9da0a-ab54-437f-9ab5-549e886d3c83.txt 2025-06-06 18:06:37.516240292 +0800
+++ tmp.pickle 2025-06-06 18:44:29.165722062 +0800
@@ -1,445 +1,85 @@
-ccopy_reg
-_reconstructor
-p0
-(ctaskw_ng.task
-Task
+(dp0
+Vdescription Update: scratch that, I don't fully understand what's going on, but it seems that some intermediate function calls are included into the pickle, and that's why it fails with this file, and doesn't with resulting data structure. |
It's a Python 2 compatibility shield, as far as I can tell. But I can't see why that would suddenly break things in 3.13. |
@ZeroIntensity, do you think pickle should load the attached file without error? |
No idea, it's impossible to tell without seeing the code. It's most likely an issue with |
Problem with that is taskw_ng doesn't cause this error. Furthermore it's not even in the stacktrace:
And I'm not sure at what point and with what version of that library was this pickle file created, but I am sure that it wasn't causing an error until the upgrade. I could report it to syncall or bubop, but looking at their code I don't see any misuse either. What such misuse could possibly even look like? At the same time calling |
Can you send the code that is creating the file? |
What is It looks like in version that created the pickle data, Look what versions of the library that provides This is an interesting problem. It cannot be solved at the user side (implementing This all happens only with historical pickle protocols 0 and 1. The best chance to recover your data is to use an older version of the library to unpickle it and then pickle it using a newer pickle protocol. |
I think it's the code where
It's Thanks for breaking it down, @serhiy-storchaka, this roughly matches my timeline with these files and Python upgrades. Let me know if I can do more to investigate it! |
Uh oh!
There was an error while loading. Please reload this page.
Bug description:
It seems that
cls.__new__(cls)
is the correct way to achieve the desired effect for any type of object?This issue was not present in 3.12, or at least same code on same pickles used to work.
I was not able to reproduce this with arbitrary data serialization/deserialization (e.g.
pickle.dump(tzutc(), f); pickle.load(f)
works), which suggests this is dependent on how exactly data is structured, and so I'm including the culprit pickle here: 74b9da0a-ab54-437f-9ab5-549e886d3c83.txtCPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: