python / python/cpython

Support qualified referencing for `ntpath.abspath()`

Open
#126,782 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

from @eryksun (https://github.com/python/cpython/pull/117855#discussion_r1579025703):

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:
  • #117587
  • #119826
Linked PRs
  • gh-119849
  • gh-126784

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ntpath.abspath() entry point and read the linked discussions in #117587 and #119826, along with PRs #119849 and #126784. Reproduce the Windows examples for './con' and './Z:spam'; done means qualified references retain their intended behavior without regressing existing abspath handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.