You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
glob.translate() rejects non-recursive pattern segments that include "**" #116377
glob.translate(recursive=True) (new in 3.13) rejects any pattern with a segment that includes **, unless ** is the entire segment. For example, translate('**a') is rejected but not translate('**')
Rejecting such segments is longstanding pathlib behaviour, but it has no precedent in the glob module -- glob.glob(recursive=True) happily accepts such segments.
>>>importglob>>>glob.glob('**.py', recursive=True)
['blah.py']
>>>glob.translate('**.py', recursive=True)
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>glob.translate('**.py', recursive=True)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^File"/home/barney/projects/cpython/Lib/glob.py", line304, intranslateraiseValueError("Invalid pattern: '**' can only be an entire path component")
ValueError: Invalidpattern: '**'canonlybeanentirepathcomponent
translate() should treat these segments similar to glob(), and leave the pattern validation stuff to pathlib.
Activity
pythonGH-116377: Stop raising `ValueError` from `glob.translate()`.
terryjreedy commentedon Mar 5, 2024
Seems sensible to me.
pythonGH-116377: Stop raising `ValueError` from `glob.translate()`.
GH-116377: Stop raising `ValueError` from `glob.translate()`. (#116378)
pythonGH-116377: Stop raising `ValueError` from `glob.translate()`. (p…
pythonGH-116377: Stop raising `ValueError` from `glob.translate()`. (p…
pythonGH-116377: Stop raising `ValueError` from `glob.translate()`. (p…