8000 pathlib.Path.rglob("") raises IndexError in Python 3.11b1 · Issue #92550 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
pathlib.Path.rglob("") raises IndexError in Python 3.11b1 #92550
Closed
@bluetech

Description

@bluetech

Bug report

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).

    def rglob(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,))
        if drv or root:
            raise NotImplementedError("Non-relative patterns are unsupported")
>       if pattern[-1] in (self._flavour.sep, self._flavour.altsep):
E       IndexError: string index out of range

rglob is documented as

This is like calling Path.glob() with “**/” added in front of the given relative pattern

so I think "" is a valid input to rglob().

Pretty sure this was introduced in ea2f5bc/#10349.

Your environment

  • CPython versions tested on: 3.11b1
  • Operating system and architecture: Both Linux and Windows.

Cross-ref: pytest-dev/pytest#9930

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0