Skip to content

Support qualified referencing for ntpath.abspath() #126782

Open
@nineteendo

Description

@nineteendo

Feature or enhancement

Proposal:

from @eryksun (#117855 (comment)):

Offhand I can't remember why normpath() gets called first. The fact that it removes an initial "." component is even more of a nuisance now. It prevents qualified referencing of files with certain DOS device names in the working directory such as "./con" versus unqualified "con". Support for the latter was added in Windows 11. For example:

>>> nt._getfullpathname('./con')
'C:\\Temp\\con'
>>> nt._getfullpathname('con')
'\\\\.\\con'
>>> os.path.abspath('./con')
'\\\\.\\con'

Calling normpath() first was always an issue for unambiguous references to file streams of single-letter filenames in the current directory. For example:

>>> nt._getfullpathname('./Z:spam')
'C:\\Temp\\Z:spam'
>>> os.path.abspath('./Z:spam')
'Z:\\spam'

Windows would beg to differ about the significance of a leading "." component, in these cases and others. Anyway, I thought this version could at least address the inconsistent behavior with embedded null characters, while still calling normpath() first.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions