python / python/cpython

Support qualified referencing for `ntpath.abspath()`

Aperta
#126,782 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal punto di ingresso ntpath.abspath() e leggi le discussioni collegate in #117587 e #119826, insieme alle PR #119849 e #126784. Riproduci gli esempi Windows per './con' e './Z:spam'; il lavoro è completato quando i riferimenti qualificati mantengono il comportamento previsto senza regressioni nella gestione esistente di abspath.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
operating-systems
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.