Skip to content

pathlib.[r]glob fails when the toplevel directory is not readable, whereas glob.glob "succeeds" #78988

Closed

Description

@anntzer
mannequin
BPO 34807
Nosy @anntzer, @tirkarthi

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:

assignee = None
closed_at = None
created_at = <Date 2018-09-26.08:36:33.686>
labels = ['3.7', 'library']
title = 'pathlib.[r]glob fails when the toplevel directory is not readable, whereas glob.glob "succeeds"'
updated_at = <Date 2018-09-26.12:43:56.029>
user = 'https://github.com/anntzer'

bugs.python.org fields:

activity = <Date 2018-09-26.12:43:56.029>
actor = 'xtreak'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2018-09-26.08:36:33.686>
creator = 'Antony.Lee'
dependencies = []
files = []
hgrepos = []
issue_num = 34807
keywords = []
message_count = 1.0
messages = ['326432']
nosy_count = 2.0
nosy_names = ['Antony.Lee', 'xtreak']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue34807'
versions = ['Python 3.7']

Linked PRs

Activity

  1. anntzer commented on Sep 26, 2018

    anntzermannequin
    MannequinAuthor

    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.

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Sep 26, 2018
  3. transferred this issue fromon Apr 10, 2022
  4. added 5 commits that reference this issue on Jan 13, 2024
  5. added a commit that references this issue on Jan 22, 2024
  6. added a commit that references this issue on Feb 11, 2024
  7. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytopic-pathlib

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions