mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
GH-79634: Accept path-like objects as pathlib glob patterns. (#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.
This commit is contained in:
parent
681e9e85a2
commit
6313cdde58
6 changed files with 115 additions and 72 deletions
|
@ -1036,6 +1036,9 @@ call fails (for example because the path doesn't exist).
|
|||
future Python release, patterns with this ending will match both files
|
||||
and directories. Add a trailing slash to match only directories.
|
||||
|
||||
.. versionchanged:: 3.13
|
||||
The *pattern* parameter accepts a :term:`path-like object`.
|
||||
|
||||
.. method:: Path.group(*, follow_symlinks=True)
|
||||
|
||||
Return the name of the group owning the file. :exc:`KeyError` is raised
|
||||
|
@ -1498,6 +1501,9 @@ call fails (for example because the path doesn't exist).
|
|||
.. versionchanged:: 3.13
|
||||
The *follow_symlinks* parameter was added.
|
||||
|
||||
.. versionchanged:: 3.13
|
||||
The *pattern* parameter accepts a :term:`path-like object`.
|
||||
|
||||
.. method:: Path.rmdir()
|
||||
|
||||
Remove this directory. The directory must be empty.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue