python / python/cpython

realpath(..., strict=ALLOW_MISSING) can unexpectedly succeed on Windows

未关闭
#135,122 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

3.13 3.14 3.15 extension-modules OS-windows type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

In new tests added for #117562 I noticed that os.path.realpath('file1/file2', strict=os.path.ALLOW_MISSING) returns 'file1/file2' when file file1 exist on Windows.

On Posix you will get NotADirectoryError here, but Windows raises ALLOW_MISSING if the intermediate path is a file instead of directory, and it will be ignored with ALLOW_MISSING.

It is expected that if realpath(..., strict=ALLOW_MISSING) does not fail, you can simply create intermediate directories or the final file/directory. At least on Posix. But on Windows it will always fail, because there is already a file here.

cc @encukou

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先复现报告中描述的 os.path.realpath('file1/file2', strict=os.path.ALLOW_MISSING) 的 Windows 行为,然后将其与 #117562 中的新测试以及相应的 POSIX 结果进行比较。当现有的中间文件不被视为有效的缺失路径,并且相关的 Windows 测试通过时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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