-
-
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
Make pickle generated by Python 3.x compatible with 2.x and vice-versa. #50387
Comments
Hello, while porting something to Python 3.1a1 Found this comment by Skip Montanaro in related issue: Could not find an issue opened for this though. Regards, |
bpo-3675 is a similar issue, too bad nothing could be done to solve it... |
If I understood correctly, bpo-3675 is about making pickle data generated I have a patch that make Unpickler translates the old names to the new |
Only if a protocol <= 2 is specified. Therefore it seems it's "only" a |
Applied the patch
Thanks, |
Some comments on the patch:
|
Unpickling e.g. StringIO objects doesn't seem to work: >>> s = pickle.load(open("stringio.pickle", "rb"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/antoine/py3k/picklecompat-6137/Lib/pickle.py", line 1351,
in load
encoding=encoding, errors=errors).load()
AttributeError: '_io.BytesIO' object has no attribute '__dict__'
>>> |
An improved patch with tests. |
A new patch which also includes reverse mappings, so that protocol <= 2 |
Updated patch with a couple of documentation and function prototype fixes. |
Sorry, last patch had a couple of minor issues |
Here is an updated patch based on Antoine's latest patch. Summary of changes:
I don't really the idea of remapping names generated by Pickler, since |
The latest patch is missing the file "Lib/_compat.pickle.py". (Seems as |
Oops. Here is a new patch with _compat_pickle.py. |
Committed in r73236 in the hope that it gets a bit more testing before |
I think it is worth noting that now some Python 3.1 protocol 2 pickles |
I've added an entry in the what's new file in r73254. |
Guido, Raymond suggested we ask your input on this one, although it's |
I'm not on IRC. What exactly is your question for me? What is Raymond's |
I vaguely remember you rejecting a proposal along these lines when Brett The patch (as applied) turns on the renaming automatically when used I don't care much one way or the other. Just thought you should see it FWIW, the argument for leaving the default as True is the theory that |
Ah. How about only doing back-translation when protocol=2 (or lower) I don't much like that 3.0 will be to read pickles written by 3.1 with |
Well, this is exactly what is implemented!
I suppose you meant to say "will be unable", but it isn't, since |
On Tue, Jun 9, 2009 at 12:16 PM, Antoine Pitrou<report@bugs.python.org> wrote:
Ah, I missed that. Fine then!
Indeed.
Good. So I'm okay with the status quo -- too bad 3.0 can't read those |
Thanks for taking a look and opining. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: