Skip to content

GH-79634: Accept path-like objects as pathlib glob patterns. - #114017

Merged
barneygale merged 7 commits into
python:mainfrom
barneygale:glob-pathlike-2
Jan 20, 2024
Merged

barneygale merged 7 commits into
python:mainfrom
barneygale:glob-pathlike-2

Conversation

@barneygale

@barneygale barneygale commented Jan 13, 2024 •

Copy link
Copy Markdown
Contributor

Allow os.PathLike objects to be passed as patterns to pathlib.Path.glob() and rglob().

(It's already possible to use them in PurePath.match())

While we're in the area:

  • Allow empty glob patterns in PathBase (but not Path)
  • Speed up globbing in PathBase by generating paths with trailing slashes only as a final step, rather than for every intermediate directory.
  • Simplify and speed up handling of rare patterns involving both ** and .. segments.


📚 Documentation preview 📚: https://cpython-previews--114017.org.readthedocs.build/

Allow `os.PathLike` objects to be passed as patterns to
`pathlib.Path.glob()` and `rglob()`.
@barneygale
barneygale merged commit 6313cdd into python:main Jan 20, 2024
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
…ython#114017)

Allow `os.PathLike` objects to be passed as patterns to `pathlib.Path.glob()` and `rglob()`. (It's already possible to use them in `PurePath.match()`)

While we're in the area:

- Allow empty glob patterns in `PathBase` (but not `Path`)
- Speed up globbing in `PathBase` by generating paths with trailing slashes only as a final step, rather than for every intermediate directory.
- Simplify and speed up handling of rare patterns involving both `**` and `..` segments.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…ython#114017)

Allow `os.PathLike` objects to be passed as patterns to `pathlib.Path.glob()` and `rglob()`. (It's already possible to use them in `PurePath.match()`)

While we're in the area:

- Allow empty glob patterns in `PathBase` (but not `Path`)
- Speed up globbing in `PathBase` by generating paths with trailing slashes only as a final step, rather than for every intermediate directory.
- Simplify and speed up handling of rare patterns involving both `**` and `..` segments.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…ython#114017)

Allow `os.PathLike` objects to be passed as patterns to `pathlib.Path.glob()` and `rglob()`. (It's already possible to use them in `PurePath.match()`)

While we're in the area:

- Allow empty glob patterns in `PathBase` (but not `Path`)
- Speed up globbing in `PathBase` by generating paths with trailing slashes only as a final step, rather than for every intermediate directory.
- Simplify and speed up handling of rare patterns involving both `**` and `..` segments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-pathlib type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant