ed...@openmail.cc
unread,Oct 23, 2019, 3:25:10 PM10/23/19You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hello,
I hope that I am writing to the right list.
Python 3.7.4 on GNU/Linux Parabola 5.3.1-gnu-1 x86_64 AMD
Issue:
I got a .pickle which had some WindowsPath inside. I was unable to
unpickle like this:
┌────
│ import pickle as pkl
│ from pathlib import Path, PureWindowsPath, PurePath, PurePosixPath,
WindowsPath, PosixPath
│ fname = "ohw_analysis.pickle"
│ # fpath = PureWindowsPath(fname)
│ fpath = Path(fname)
│ with open(fpath, "rb") as fd:
│ # Works in Winbug$ only
│ ohw_analysis = pkl.load(fd)
└────
I tried to create my own class to override =_new= in =Path=, but that
did not work, because (I assume that) the pickle data was pointing to
=pathlib=. I did not know how to solve this, so I modified the code for
pathlib.py
Solution:
The modification allowed me to unpickle the file, and I think that it
would not break =pathlib=. I have seen this issue reported elsewhere,
and I thought that it could be useful to others.
Extra:
I really hope that this is useful. Although I am not asking for help, if
there was a better solution, let me know. I don't want a Github account
(Micro$oft).
Thanks!