-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
pathlib: Path.exists broken #66948
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
Comments
$ touch a
c: stat("a/x", ...) -> errno=ENOTDIR
$ python
>>> pathlib.Path('a/x').exists() This should return False and not throw an exception. Patch not tested. |
Tested and works. |
os.path.exists() ignores *all* OSErrors from stat. This is probably too broad, but only ignoring ENOENT is probably too narrow. |
ENAMETOOLONG and possibly ELOOP should also return False. |
ENAMETOOLONG: that doesn't mean the file doesn't exist. For example, it could be accessed by changing the current directory and shortening the residual path name. ELOOP: unfortunately it doesn't guarantee that there is a real symlink loop, just that the OS decided to bail out after a certain number of indirections. So in both cases I think we should let the errors bubble up. |
Here is a patch with tests. |
Should I file bugs for is_dir, is_file, is_symlink, is_socket, is_fifo, is_block_device and is_char_device? |
Le 30/10/2014 20:36, Hristo Venev a écrit :
Hmm... good catch. No, this issue will do. |
Updated patch for other querying function. |
New changeset 40497cc445f4 by Antoine Pitrou in branch '3.4': New changeset ff5f5fd230d3 by Antoine Pitrou in branch 'default': |
This is now fixed. Thanks for the report! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: