[New-bugs-announce] [issue34807] pathlib.[r]glob fails when the toplevel directory is not readable, whereas glob.glob "succeeds"

Antony Lee report at bugs.python.org
Wed Sep 26 04:36:33 EDT 2018


New submission from Antony Lee <anntzer.lee at gmail.com>:

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.

----------
components: Library (Lib)
messages: 326432
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: pathlib.[r]glob fails when the toplevel directory is not readable, whereas glob.glob "succeeds"
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34807>
_______________________________________


More information about the New-bugs-announce mailing list