-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nturl2path.pathname2url()
doesn't handle forward slashes
#120423
Comments
Quoting @eryksun:
|
While using an empty authority (i.e. hostname or namespace) for a UNC path is valid according to RFC8089 (e.g. "file:////spam/eggs/foo"), the two-slash form with an authority is preferred on Windows (e.g. "file://spam/eggs/foo"). For DOS drive paths, the form with an empty authority is preferred (e.g. "file:///C:/eggs/foo"). But using an explicit authority is also supported (e.g. "file://localhost/C:/eggs/foo", or sometimes "file://./C:/eggs/foo"). |
On POSIX, >>> 'file://' + urllib.request.pathname2url('/etc/hosts')
'file:///etc/hosts' But if we try the same thing using the Windows version we get unusual results: >>> 'file://' + nturl2path.pathname2url(r'c:\foo')
'file://///C:/foo'
>>> 'file://' + nturl2path.pathname2url('c:/foo')
'file://///C://foo'
>>> 'file://' + nturl2path.pathname2url(r'\\server\share\file')
'file://////server/share/file'
>>> 'file://' + nturl2path.pathname2url('//server/share/file')
'file:////server/share/file' I don't think there's a way to use it correctly. IMHO we should deprecate + remove it. |
We can recommend It's tempting to also deprecate and remove
|
If we want to encourage usage of |
#126148 will fix this |
Thanks, I was already wondering if that was the case. |
…paths Adjust `urllib.request.pathname2url()` so that forward slashes in Windows paths are handled identically to backward slashes.
…126593) Adjust `urllib.request.pathname2url()` so that forward slashes in Windows paths are handled identically to backward slashes.
…paths (pythonGH-126593) Adjust `urllib.request.pathname2url()` so that forward slashes in Windows paths are handled identically to backward slashes. (cherry picked from commit bf224bd) Co-authored-by: Barney Gale <[email protected]>
…paths (pythonGH-126593) Adjust `urllib.request.pathname2url()` so that forward slashes in Windows paths are handled identically to backward slashes. (cherry picked from commit bf224bd) Co-authored-by: Barney Gale <[email protected]>
… paths (GH-126593) (#126763) GH-120423: `pathname2url()`: handle forward slashes in Windows paths (GH-126593) Adjust `urllib.request.pathname2url()` so that forward slashes in Windows paths are handled identically to backward slashes. (cherry picked from commit bf224bd) Co-authored-by: Barney Gale <[email protected]>
… paths (GH-126593) (#126764) GH-120423: `pathname2url()`: handle forward slashes in Windows paths (GH-126593) Adjust `urllib.request.pathname2url()` so that forward slashes in Windows paths are handled identically to backward slashes. (cherry picked from commit bf224bd) Co-authored-by: Barney Gale <[email protected]>
Fixed! Thanks for your input, all. |
Bug report
Bug description:
Paths with forward slashes aren't handled the same as paths with backslashes:
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Linked PRs
pathname2url()
: handle forward slashes in Windows paths #126593pathname2url()
: handle forward slashes in Windows paths (GH-126593) #126763pathname2url()
: handle forward slashes in Windows paths (GH-126593) #126764The text was updated successfully, but these errors were encountered: