1. Antoine Pitrou
  2. pathlib
  3. Issues
Issue #17 resolved

pickle fails to unserialize path

Alexey
created an issue

Unserialized object does not contain all the fields. E.g. hash(path) fails

In [1]: import pathlib, pickle

In [2]: hash(pickle.loads(pickle.dumps(pathlib.PurePosixPath("/some/path"))))
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-07cfed634e34> in <module>()
----> 1 hash(pickle.loads(pickle.dumps(pathlib.PurePosixPath("/some/path"))))

/usr/local/lib/python2.7/dist-packages/pathlib.pyc in __hash__(self)
    838             return self._hash
    839         except AttributeError:
--> 840             self._hash = hash(tuple(self._cparts))
    841             return self._hash
    842 

/usr/local/lib/python2.7/dist-packages/pathlib.pyc in _cparts(self)
    823             return self._cached_cparts
    824         except AttributeError:
--> 825             self._cached_cparts = self._flavour.casefold_parts(self._parts)
    826             return self._cached_cparts
    827 

AttributeError: _parts

Comments (1)

  1. Log in to comment