You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because our pathlib.Path objects contain strings which need to marshalled to unicode on loading into Python 3.
The default for Python 3 loading a Python 2 pickle is to only decode valid ASCII characters to strings. If you come across an invalid character, you get this:
/.../lib/python3.5/site-packages/menpo/io/input/base.py in
_import(filepath, extensions_map, landmark_resolver, landmark_ext_map,
landmark_attach_func, asset, importer_kwargs)
802 if importer_kwargs is None:
803 importer_kwargs = {}
--> 804 built_objects = importer_callable(path, asset=asset, **importer_kwargs)
805
806 # landmarks are iterable so check for list precisely
/.../lib/python3.5/site-packages/menpo/io/input/pickle.py in
pickle_importer(filepath, asset, **kwargs)
25 """
26 with open(str(filepath), 'rb') as f:
---> 27 x = pickle.load(f)
28 return x
29
UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position 2:
ordinal not in range(128)
A solution to this is to change the import encoding to latin1 in Python 3:
We should also bear in mind that we may head towards Python 3 only support (#721). This issue is both an example of the kind of burden we could rid ourselves of by moving sooner, and potentially something that isn't worth solving if a commitment to Python 3 is on the horizon (i.e. - rather than muddy the waters our official stance can be Python 2/3 pickles are incompatible and we can just remove this confusion down the line by some point dropping Python 2).
The text was updated successfully, but these errors were encountered:
This is because our
pathlib.Path
objects contain strings which need to marshalled to unicode on loading into Python 3.The default for Python 3 loading a Python 2 pickle is to only decode valid ASCII characters to strings. If you come across an invalid character, you get this:
A solution to this is to change the import encoding to
latin1
in Python 3:However this is a bold change to make so I'm making this issue to think through any possible consequences.
If we decided to do this, note that we would need a Python version check to add it, as
pickle.load()
in Python 2.7 does not take any kwargs.We should also bear in mind that we may head towards Python 3 only support (#721). This issue is both an example of the kind of burden we could rid ourselves of by moving sooner, and potentially something that isn't worth solving if a commitment to Python 3 is on the horizon (i.e. - rather than muddy the waters our official stance can be Python 2/3 pickles are incompatible and we can just remove this confusion down the line by some point dropping Python 2).
The text was updated successfully, but these errors were encountered: