-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Document that glob functions in pathlib and glob modules ignore access errors #146646
Copy link
Copy link
Open
Labels
Description
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:
pathlib.Path.glob()- https://docs.python.org/3/library/pathlib.html#pathlib.Path.globpathlib.Path.rglob()- https://docs.python.org/3/library/pathlib.html#pathlib.Path.rglob- "Comparison to the
globmodule" section inpathlibdocs - https://docs.python.org/3/library/pathlib.html#comparison-to-the-glob-module globmodule - https://docs.python.org/3/library/glob.html
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")
[]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
No status
Status
No status
Status
Todo