This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ikelos
Recipients ikelos
Date 2022-02-05.22:27:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644100059.97.0.383989396746.issue46654@roundup.psfhosted.org>
In-reply-to
Content
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...
History
Date User Action Args
2022-02-05 22:27:39ikelossetrecipients: + ikelos
2022-02-05 22:27:39ikelossetmessageid: <1644100059.97.0.383989396746.issue46654@roundup.psfhosted.org>
2022-02-05 22:27:39ikeloslinkissue46654 messages
2022-02-05 22:27:39ikeloscreate