Skip to content
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 dumps not readable between python 2/3 #22

Open
kain88-de opened this issue Aug 21, 2017 · 8 comments
Open

Pickle dumps not readable between python 2/3 #22

kain88-de opened this issue Aug 21, 2017 · 8 comments

Comments

@kain88-de
Copy link
Contributor

The problem is that we always write using the highest available protocol. But I was unaware that python3 introduced a new protocol version

https://stackoverflow.com/questions/25843698/valueerror-unsupported-pickle-protocol-3-python2-pickle-can-not-load-the-file#25843743

To have pickles load across python version and be reasonable fast/small we have to explicitly choose version 2 of the protocol.

@richardjgowers
Copy link
Contributor

What are we using pickles for?

@kain88-de
Copy link
Contributor Author

python data pickles. For example if we store python objects.

@richardjgowers
Copy link
Contributor

Right yeah, but what is datreant using pickle for? git grep pickle isn't showing me anything?

@kain88-de
Copy link
Contributor Author

pickle.dump(data, self.handle, pickle.HIGHEST_PROTOCOL)

Sure you are on the right repository?

@richardjgowers
Copy link
Contributor

Ah right yeah, I was looking at core

@kain88-de
Copy link
Contributor Author

Oh well with string handling this is even more broken -.-. We have to check reading/writing with the bytes flags rb/wb to ensure data can be read/written independent of the python version.

@kain88-de
Copy link
Contributor Author

This is to say. I now also encountered that a python2 dump cannot be read by python 3

@kain88-de kain88-de changed the title python3 pickle dumps are not readable in python 2 Pickle dumps not readable between python 2/3 Aug 21, 2017
@kain88-de
Copy link
Contributor Author

https://bugs.python.org/issue6784

So they claim this is resolved. But I honestly haven't found a good solution today to enable reading / writing of pickles between python versions that works problem free. Some simple stiff and builtin types might work but not complex objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants