-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
gh-96290: support partial/invalid UNC drives in normpath() and splitdrive() #100351
Conversation
471c47b
to
7ab642b
Compare
…splitdrive() This brings the Python implementation of `ntpath.normpath()` in line with the C implementation added in 99fcf15 Co-authored-by: Eryk Sun <eryksun@gmail.com>
7ab642b
to
1fb70c7
Compare
Almost. The C implementation is incorrect for "UNC" device paths. For example: >>> nt._path_normpath('//?/UNC/server/share/..')
'\\\\?\\UNC\\server' The problem is that it handles "//?/UNC/" as the root instead of "//?/UNC/server/share/". The pure Python implementation gets it right. |
I've changed "in line" to "more in line" :-) |
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
If Eryk and Barney both say this is ready, I'm happy to merge. |
It's ready to land I think! |
A long-standing issue with tester('ntpath.isabs("\\\\conky\\mountpoint")', 1)
tester('ntpath.isabs("\\\\.\\C:")', 1) |
@zooba, it's ready to be merged. |
Thanks @barneygale for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, @barneygale and @zooba, I could not cleanly backport this to |
GH-100999 is a backport of this pull request to the 3.11 branch. |
…() and splitdrive() (pythonGH-100351) This brings the Python implementation of `ntpath.normpath()` in line with the C implementation added in 99fcf15 Co-authored-by: Eryk Sun <eryksun@gmail.com>
Thank you both! |
Fix handling of partial and invalid UNC drives in
ntpath.splitdrive()
, and inntpath.normpath()
on non-Windows systems.Paths such as
\\server
and\\
are now considered bysplitdrive()
to contain only a drive, and consequently are not modified bynormpath()
on non-Windows systems. The behaviour ofnormpath()
on Windows systems is unaffected, as native OS APIs are used.This brings the Python implementation of
ntpath.normpath()
more in line with the C implementation added in 99fcf15.Implementation by @eryksun. I added tests and NEWS.