python / python/cpython

properly define what "canonical" means in `os.path.realpath`

未关闭
#134,639 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

Documentation

The documentation says:
https://github.com/python/cpython/blob/2fd09b011031f3c00c342b44e02e2817010e507c/Doc/library/os.path.rst?plain=1#L406-L409

So it merely mentions symlink resolution, but not what else it means (if anything).

It does however mention that whatever it does is OS dependent:
https://github.com/python/cpython/blob/2fd09b011031f3c00c342b44e02e2817010e507c/Doc/library/os.path.rst?plain=1#L416-L418

IMO, it should be clearly documented what it does or at least:

  • what it guarantees to the least (For example will the pathname be absolute? Will it be normalised?)
    and/or:
  • which OS function it’s identical to, like on POSIX where that would probably realpath(), and whether there are differences to that

Especially since IMO "canonical" pathname (though I think it has no formal definition, or is there anything in POSIX?) means rather just that there are no symlinks left, i.e. that the file is "reached" by its true (=canonical) name.

But that could still be a relative pathname, and perhaps even one that is not normalised.

Cheers,
Chris.

Linked PRs
  • gh-134755

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 Doc/library/os.path.rst 中引用的第 406-409 行和第 416-418 行开始,然后与 issue 中链接的 POSIX realpath() 参考文档进行比较。记录 os.path.realpath 的最低保证,以及任何特定于操作系统的行为或差异,并确保措辞明确说明“canonical”的含义。

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

评估

技术栈
python
领域
documentation
Issue 类型
文档
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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