python / python/cpython

Support qualified referencing for `ntpath.abspath()`

未关闭
#126,782 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

type-feature
主要语言
Python
星标
77.2k
派生
36k
PR 合并指标
PR 指标待抓取

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 ntpath.abspath() 入口点开始,阅读 #117587 和 #119826 中链接的讨论,以及 PR #119849 和 #126784。复现 './con' 和 './Z:spam' 的 Windows 示例;完成的标准是限定引用保留其预期行为,且不会使现有的 abspath 处理发生回归。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
operating-systems
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。