-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
os.path.splitext()
can split UNC drive on Windows
#115892
Comments
I don't think this is necessarily an "obvious" change to make. We don't currently validate anything about the path, so it works on relative and absolute paths alike. This would introduce validation at the start, making new assumptions about the type of path we've been given. Meanwhile, there's nothing actually bad about splitting the share name like this? No file operation is going to work on it anyway, so you're about to get an error even if you don't at this step, and if you know you've got a UNC share or a directory path, why are you asking for its suffix? I feel like this is too risky to backport, and I'm not convinced of the value going forward given that we currently don't require a full or relative path (and probably shouldn't). |
os.path.splitext() on Windows no longer splits an "extension" from the server or share name in the UNC path.
It's it worth fixing this with splitroot? Or do we close this? |
I think we should close. Fixing this would suggest we should also detect directories with |
I don't think that's what @barneygale had in mind. He doesn't like the inconsistency with >>> import ntpath
>>> ntpath.split('//server/share.jpg')
('//server/share.jpg', '') # empty basename
>>> ntpath.splitext('//server/share.jpg')
('//server/share', '.jpg') # but extension? |
I'm sure I can come up with a justification, but really, both operations are somewhat nonsense (or more politely, a boundary condition), so the result can be arbitrary. Arbitrarily, I'd like the (I guess you could reasonably argue that |
Bug report
This path has an empty basename, and so its suffix should also be empty. Affects all current Python versions.
Linked PRs
The text was updated successfully, but these errors were encountered: