mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
GH-70303: Emit FutureWarning when pathlib glob pattern ends with **
(GH-105413)
In a future Python release, patterns with this ending will match both files and directories. Users may add a trailing slash to remove the warning.
This commit is contained in:
parent
2c25bd82f4
commit
ec0a0d2bd9
4 changed files with 30 additions and 3 deletions
|
@ -1069,6 +1069,11 @@ class Path(PurePath):
|
|||
pattern_parts.append('')
|
||||
if pattern_parts[-1] == '**':
|
||||
# GH-70303: '**' only matches directories. Add trailing slash.
|
||||
warnings.warn(
|
||||
"Pattern ending '**' will match files and directories in a "
|
||||
"future Python release. Add a trailing slash to match only "
|
||||
"directories and remove this warning.",
|
||||
FutureWarning, 3)
|
||||
pattern_parts.append('')
|
||||
|
||||
if case_sensitive is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue