Include the current working dir in FileNotFoundError
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 558
描述
Feature or enhancement
A FileNotFoundError exception should include the current working directory when referring to a relative path.
Pitch
The problem this solves is with relative paths. If you just get the error "foo/bar not found", it is not enough info to fully understand the problem, because whether this can be found depends on the working directory as well.
At the moment, I'm working with Bazel (a build system), which does its form of sandboxing by symlinking things into a separate directory and building there. This implies both creating files/symlinks and switching directories and a lot of that. When a file is not found, it can mean that either of the two operations were faulty, but with a relative path you absolutely need the working directory to say which is the case.
Note that there is another category of similar problems, where e.g. Popen() tries to locate an executable using the PATH environment variable. Here, the simple executable file name is not helpful without the directories that were searched.
Previous discussion
I have found #60389, which is also related to missing info in such an error. Apart from that, I haven't found any similar discussions.
Linked PRs
- gh-116071
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先追踪 Python 在相对路径上引发 FileNotFoundError 的位置,并检查 issue 中提到的相关 Popen() 行为。当缺失的相对路径报告当前工作目录,同时保留通过 PATH 解析的路径的有用错误行为时,此更改即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100