Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue22759

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:pathlib: Path.exists broken
Type:behaviorStage:resolved
Components:Versions:Python 3.4, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: georg.brandl, h.venev, pitrou, python-dev
Priority:normalKeywords:patch

Created on2014-10-29 15:30 byh.venev, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
py.patchh.venev,2014-10-29 15:30
path_exists_enotdir.patchpitrou,2014-10-30 19:30
path_exists_enotdir2.patchpitrou,2014-10-30 19:40
Messages (11)
msg230214 -(view)Author: Hristo Venev (h.venev)*Date: 2014-10-29 15:30
$ touch ac: stat("a/x", ...) -> errno=ENOTDIR$ python>>> pathlib.Path('a/x').exists()This should return False and not throw an exception.Patch not tested.
msg230221 -(view)Author: Hristo Venev (h.venev)*Date: 2014-10-29 15:55
Tested and works.
msg230222 -(view)Author: Georg Brandl (georg.brandl)*(Python committer)Date: 2014-10-29 16:00
os.path.exists() ignores *all* OSErrors from stat.  This is probably too broad, but only ignoring ENOENT is probably too narrow.
msg230225 -(view)Author: Hristo Venev (h.venev)*Date: 2014-10-29 16:13
ENAMETOOLONG and possibly ELOOP should also return False.EACCES, EOVERFLOW and ENOMEM should probably be forwarded.EFAULT should not happen.
msg230292 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2014-10-30 19:25
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.
msg230293 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2014-10-30 19:30
Here is a patch with tests.
msg230294 -(view)Author: Hristo Venev (h.venev)*Date: 2014-10-30 19:36
Should I file bugs for is_dir, is_file, is_symlink, is_socket, is_fifo, is_block_device and is_char_device?
msg230295 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2014-10-30 19:37
Le 30/10/2014 20:36, Hristo Venev a écrit :> > Hristo Venev added the comment:> > Should I file bugs for is_dir, is_file, is_symlink, is_socket, is_fifo, is_block_device and is_char_device?Hmm... good catch. No, this issue will do.
msg230297 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2014-10-30 19:40
Updated patch for other querying function.
msg230303 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-10-30 22:15
New changeset40497cc445f4 by Antoine Pitrou in branch '3.4':Issue#22759: Query methods on pathlib.Path() (exists(), is_dir(), etc.) now return False when the underlying stat call raises NotADirectoryError.https://hg.python.org/cpython/rev/40497cc445f4New changesetff5f5fd230d3 by Antoine Pitrou in branch 'default':Issue#22759: Query methods on pathlib.Path() (exists(), is_dir(), etc.) now return False when the underlying stat call raises NotADirectoryError.https://hg.python.org/cpython/rev/ff5f5fd230d3
msg230304 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2014-10-30 22:16
This is now fixed. Thanks for the report!
History
DateUserActionArgs
2022-04-11 14:58:09adminsetgithub: 66948
2014-10-30 22:16:28pitrousetstatus: open -> closed
resolution: fixed
messages: +msg230304

stage: patch review -> resolved
2014-10-30 22:15:42python-devsetnosy: +python-dev
messages: +msg230303
2014-10-30 19:40:37pitrousetfiles: +path_exists_enotdir2.patch

messages: +msg230297
2014-10-30 19:37:34pitrousetmessages: +msg230295
2014-10-30 19:36:53h.venevsetmessages: +msg230294
2014-10-30 19:30:55pitrousetfiles: +path_exists_enotdir.patch

messages: +msg230293
stage: test needed -> patch review
2014-10-30 19:25:55pitrousetmessages: +msg230292
2014-10-29 16:13:34h.venevsetmessages: +msg230225
2014-10-29 16:00:23georg.brandlsetnosy: +georg.brandl
messages: +msg230222
2014-10-29 15:58:17pitrousetnosy: +pitrou
stage: test needed
type: behavior

versions: + Python 3.4, Python 3.5
2014-10-29 15:55:08h.venevsetmessages: +msg230221
2014-10-29 15:30:32h.venevcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp