<div dir="ltr"><div>Sure.  I use pickles to store "processed" (scientific) datasets; they typically keep the path to a "raw" dataset as an object attribute (of a Path class, either PosixPath or WindowsPath depending on the "OS" (POSIX/Windows) of the computer where the processing is originally done), as it is sometimes useful to go back and check the raw datasets.  However, in general the processed datasets are enough by themselves, so it makes sense to transfer them (independently of the raw datasets) to another computer before further processing.</div><div><br></div><div>Obviously, once the processed dataset has been transferred to another computer, trying to access the raw dataset will fail with an OSError (e.g., FileNotFoundError); I have code in place to handle that.  However, if the file is transferred from a POSIX "OS" to a Windows "OS" or vice-versa, it becomes impossible to even unpickle the file.</div><div><br></div><div>Converting Path objects to PurePaths upon unpickling on a different "OS", either silently or possibly with a warning, would allow me to just catch both OSErrors and AttributeErrors when trying to access the raw dataset from the path attribute of the processed one.</div><div><br></div><div>Antony</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-07-15 17:57 GMT-07:00 Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 07/15/2016 05:51 PM, Antony Lee wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have opened <a href="http://bugs.python.org/issue27175" rel="noreferrer" target="_blank">http://bugs.python.org/issue27175</a> a month and a half ago but didn't get any feedback there, so I'll copy-paste it here for comments:<br>
<br>
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.<br>
<br>
- 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.<br>
<br>
- Silently convert Paths to PurePaths during pickling (a solution that seems to have been adopted by <a href="http://docs.menpo.org/en/stable/api/menpo/io/export_pickle.html" rel="noreferrer" target="_blank">http://docs.menpo.org/en/stable/api/menpo/io/export_pickle.html</a> for example): it would be better if Paths at least roundtripped correctly within a single platform.<br>
<br>
- 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.<br>
<br>
Thoughts?<br>
</blockquote>
<br></span>
Any use-case examples?  That would help in deciding on the best path forward.<br>
<br>
--<br>
~Ethan~<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div><br></div>