[New-bugs-announce] [issue27175] Unpickling Path objects
Antony Lee
report at bugs.python.org
Wed Jun 1 05:18:04 EDT 2016
New submission from Antony Lee:
Currently, pickling Path objects lead to issues when working across platforms: Paths (and, thus, objects that contain Paths) created on a POSIX platform (PosixPaths) cannot be unpickled on Windows and vice versa. There are a few possibilities around this issue.
- Don't do anything about it, you should use PurePaths if you care about cross-platform compatibility: this would be pretty awkward, as any call to the Path API would require converting back the PurePath to a Path first.
- Silently convert Paths to PurePaths during pickling (a solution that seems to have been adopted by http://docs.menpo.org/en/stable/api/menpo/io/export_pickle.html for example): it would be better if Paths at least roundtripped correctly within a single platform.
- Convert Paths to PurePaths at unpickling time, only if the platform is different (and possibly with a warning): this is the least bad solution I came up with so far. Note that calls to the Path API on a "converted" PurePath object would be invalid anyways as the PurePath (being of a different platform) cannot be representing a valid path.
Thoughts?
----------
components: Library (Lib)
messages: 266810
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Unpickling Path objects
versions: Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27175>
_______________________________________
More information about the New-bugs-announce
mailing list