Skip to content

Document that glob functions in pathlib and glob modules ignore access errors #146646

@Jackenmen

Description

@Jackenmen

Documentation

Based on #68308 (and just the fact that it has stayed unchanged for years), I assume this is intentional, and so I'm only creating a docs issue.

This behaviour is not documented anywhere in the relevant documentation, and (to me) it feels a bit surprising:

Some examples (ran as a non-root user):

Python 3.14.3 (main, Feb  4 2026, 09:28:29) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> list(Path("/root").glob("*"))
[]
>>> list(Path("/root/x").glob("*"))
[]
>>> import glob
>>> glob.glob("/root/*")
[]
>>> glob.glob("*", root_dir="/root")
[]
>>> glob.glob("*", root_dir="/root", recursive=True)
[]
>>> glob.glob("/root/x/*")
[]
>>> glob.glob("*", root_dir="/root/x")
[]

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Status

    No status

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions