Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the current working dir in FileNotFoundError #93431

Open
UlrichEckhardt opened this issue Jun 2, 2022 · 1 comment
Open

Include the current working dir in FileNotFoundError #93431

UlrichEckhardt opened this issue Jun 2, 2022 · 1 comment
Labels
3.13 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@UlrichEckhardt
Copy link

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.

@UlrichEckhardt UlrichEckhardt added the type-feature A feature request or enhancement label Jun 2, 2022
@tiran
Copy link
Member

tiran commented Jun 2, 2022

For openat(2) and similar *at syscalls we would have to include the dirfd file descriptor if the dirfd argument is not AT_FDCWD. getcwd(3) would give incorrect answer.

@AA-Turner AA-Turner added the 3.12 bugs and security fixes label Jun 2, 2022
@iritkatriel iritkatriel added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 28, 2023
@erlend-aasland erlend-aasland added 3.13 new features, bugs and security fixes and removed 3.12 bugs and security fixes labels Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

5 participants