The Wayback Machine - https://web.archive.org/web/20221223145743/https://github.com/python/cpython/pull/100351
Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Dec 19, 2022

Fix handling of partial and invalid UNC drives in ntpath.splitdrive(), and in ntpath.normpath() on non-Windows systems.

Paths such as \\server and \\ are now considered by splitdrive() to contain only a drive, and consequently are not modified by normpath() on non-Windows systems. The behaviour of normpath() 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.

…splitdrive()

This brings the Python implementation of `ntpath.normpath()` in line with
the C implementation added in 99fcf15

Co-authored-by: Eryk Sun <[email protected]>
@barneygale barneygale force-pushed the gh-96290-ntpath-normpath-fix branch from 7ab642b to 1fb70c7 Compare Dec 20, 2022
@barneygale barneygale marked this pull request as ready for review Dec 20, 2022
@barneygale barneygale requested a review from brettcannon as a code owner Dec 20, 2022
@brettcannon brettcannon requested review from eryksun and a team Dec 20, 2022
@eryksun
Copy link
Contributor

eryksun commented Dec 22, 2022

This brings the Python implementation of ntpath.normpath() in line with the C implementation

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.

@barneygale
Copy link
Contributor Author

barneygale commented Dec 22, 2022

I've changed "in line" to "more in line" :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants