You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle not executable directories for os.listdir #117402
That's inconsistent behaviour: os.listdir says directory/inaccessible.txt exists, while os.path.exists says it does not.
This can be solved simply be raising a PermissionError (or a subclass) for os.listdir when the directory is not executable.
I can't think of any situation outside of a CTF where it would be useful to be able to list the files in such directories.
Note that this is different from a directory with "-wx" permisions with a file secret.txt:
os.stat() and os.listdir() propagate errors from your operating system rather than raising OSError artificially. This is not a bug, and you'll need to gather support on the ideas forum first if you want to change it.
Activity
nineteendo commentedon Mar 31, 2024
@eryksun, what do you think?
nineteendo commentedon Mar 31, 2024
@terryjreedy, this is technically not related to
pathlib. Though it would change the behaviour ofpathlib.Path.iterdir().barneygale commentedon Mar 31, 2024
os.stat()andos.listdir()propagate errors from your operating system rather than raisingOSErrorartificially. This is not a bug, and you'll need to gather support on the ideas forum first if you want to change it.