This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pathlib.[r]glob fails when the toplevel directory is not readable, whereas glob.glob "succeeds"
Type: Stage:
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Antony.Lee, xtreak
Priority: normal Keywords:

Created on 2018-09-26 08:36 by Antony.Lee, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg326432 - (view) Author: Antony Lee (Antony.Lee) * Date: 2018-09-26 08:36
After

    $ mkdir -p foo/bar && chmod 000 foo

one gets

    In [1]: glob.glob("foo/bar")
    Out[1]: []

but

    In  [2]: list(Path("foo/bar").glob("*"))

gives a PermissionError.

I'm not arguing that pathlib should reproduce glob's behavior (in fact I think raising an exception is better in this case), but this could be better documented (os.walk does indicate that "By default, errors from the scandir() call are ignored." whereas I don't think either glob or pathlib docs mention this point at all).

Compare with https://bugs.python.org/issue24120, which relates to unreadable directories found *inside* the toplevel directory.
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 78988
2018-09-26 12:43:56xtreaksetnosy: + xtreak
2018-09-26 08:36:33Antony.Leecreate