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.abspath() needs more normalization on Windows #90520
Comments
3.11a3+ introduced the C version of abspath(), which shows incompletely normalized absolute path (see msg410068): >>> os.path.abspath(r'\\spam\\eggs. . .')
'\\\\spam\\\\eggs. . .'
>>> os.path.abspath('C:\\spam. . .')
'C:\\spam. . .'
>>> os.path.abspath('C:\\nul')
'C:\\nul' The design is efficient on startup with getpath_abspath(), but ntpath.abspath()'s result after startup should be more normalized. |
Can you show various paths, before and after your change? It’s not clear to me what you’re proposing to change. |
Basically, PR30571 aims for compatibility with 3.10 and earlier. Using Windows API is the easiest and the same way as them: import os.path
paths = [
r'C:\CON',
r'C:\PRN',
r'C:\AUX',
r'C:\NUL',
r'C:\COM1',
r'C:\COM2',
r'C:\COM3',
r'C:\COM9',
r'C:\LPT1',
r'C:\LPT2',
r'C:\LPT3',
r'C:\LPT9',
r'C:\foo. . .',
]
for path in paths:
print(os.path.abspath(path)) """ 3.11 after 3.10.1 |
One thing to be aware of is that Windows 11 has changed the rules around these files, so here's my results with 3.10: >>> for path in paths:
... print(os.path.abspath(path))
...
C:\CON
C:\PRN
C:\AUX
\\.\NUL
C:\COM1
C:\COM2
C:\COM3
C:\COM9
C:\LPT1
C:\LPT2
C:\LPT3
C:\LPT9
C:\foo But this shouldn't be an issue with the proposed (about to be merged) change. |
Thanks for the patch! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: