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
pathlib.Path.rglob("") raises IndexError in Python 3.11b1 #92550
Python 3.11b1 raises with the following given path.rglob("") where path is a pathlib.Path. This worked in previous versions (and also in whichever previous alphas GitHub Actions used).
defrglob(self, pattern):
"""Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree. """sys.audit("pathlib.Path.rglob", self, pattern)
drv, root, pattern_parts=self._flavour.parse_parts((pattern,))
ifdrvorroot:
raiseNotImplementedError("Non-relative patterns are unsupported")
>ifpattern[-1] in (self._flavour.sep, self._flavour.altsep):
EIndexError: stringindexoutofrange
C:\Users\alexw\coding\cpython>git checkout ea2f5bcda1a392804487e6883be89fbad38a01a5
HEAD is now at ea2f5bcda1 bpo-22276: Change pathlib.Path.glob not to ignore trailing path separator (GH-10349)
C:\Users\alexw\coding\cpython>python
Running Debug|x64 interpreter...
Python 3.12.0a0 (main, May 9 2022, 11:32:16) [MSC v.1931 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> next(pathlib.Path().rglob(""))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\alexw\coding\cpython\Lib\pathlib.py", line 963, in rglob
if pattern[-1] in (self._flavour.sep, self._flavour.altsep):
~~~~~~~^^^^
IndexError: string index out of range
>>> exit()
C:\Users\alexw\coding\cpython>git checkout HEAD~1
Previous HEAD position was ea2f5bcda1 bpo-22276: Change pathlib.Path.glob not to ignore trailing path separator (GH-10349)
HEAD is now at 0ef8d921f5 gh-91603: Speed up isinstance/issubclass on union types (GH-91631)
C:\Users\alexw\coding\cpython>python
Running Debug|x64 interpreter...
Python 3.12.0a0 (main, May 9 2022, 11:32:16) [MSC v.1931 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> next(pathlib.Path().rglob(""))
WindowsPath('.')
>>>
Activity
AlexWaygood commentedon May 9, 2022
Yes, looks like it:
cc. @brettcannon, @barneygale
gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)
pythongh-92550 - Fix regression in `pathlib.Path.rglob()` (pythonGH-9…
gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)
serhiy-storchaka commentedon May 10, 2022
Why the whole feature was removed instead of applying a simple fix? @brettcannon
Revert "gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)"
Revert "gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)"
pythongh-92550: Fix pathlib.Path.rglob() for empty pattern
Revert "gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)…
Revert "gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)…
pythongh-92550: Fix pathlib.Path.rglob() for empty pattern (pythonGH-…
gh-92550: Fix pathlib.Path.rglob() for empty pattern (GH-92604)
gh-92550: Fix pathlib.Path.rglob() for empty pattern (GH-92604)
pythongh-92550: Fix pathlib.Path.rglob() for empty pattern (pythonGH-…