Message412602
I've found open to have difficulty with a resolved pathlib path:
Example code of:
import pathlib
path = "Z:\\test.py"
with open(path) as fp:
print("Stock open: works")
data = fp.read()
with open(pathlib.Path(path).resolve().as_uri()) as fp:
print("Pathlib resolve open")
data = fp.read()
Results in:
Z:\> python test.py
Stock open: works
Traceback (most recent call last):
File "Z:\test.py", line 12, in <module>
with open(pathlib.Path(path).resolve().as_uri()) as fp:
FileNotFoundError: [Errno 2] No such file or directory: "file://machine/share/test.py"
Interestingly, I've found that open("file:////machine/share/test.py") succeeds, but this isn't what pathlib's resolve() produces. It appears as though file_open only supports hosts that are local, but will open UNC paths on windows with the additional slashes. This is quite confusing behaviour and it's not clear why file://host/share/file won't work, but file:////host/share/file does.
I imagine this is a long time issue and a decision has already been reached on why file_open doesn't support such URIs, but I couldn't find the answer anywhere, just issue 32442 which was resolved without clarifying the situation... |
|
Date |
User |
Action |
Args |
2022-02-05 22:27:39 | ikelos | set | recipients:
+ ikelos |
2022-02-05 22:27:39 | ikelos | set | messageid: <1644100059.97.0.383989396746.issue46654@roundup.psfhosted.org> |
2022-02-05 22:27:39 | ikelos | link | issue46654 messages |
2022-02-05 22:27:39 | ikelos | create | |
|