GH-116380: Revert move of pathlib globbing code to pathlib._glob (#118678)

The previous change made the `glob` module slower to import, because it
imported `pathlib._glob` and hence the rest of `pathlib`.

Reverts a40f557d7b.
This commit is contained in:
Barney Gale 2024-05-07 01:32:48 +01:00 committed by GitHub
parent ff6cbb2503
commit b4bdf83cc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 331 additions and 337 deletions

View file

@ -12,11 +12,10 @@ resemble pathlib's PurePath and Path respectively.
"""
import functools
from glob import _Globber, _no_recurse_symlinks
from errno import ENOENT, ENOTDIR, EBADF, ELOOP, EINVAL
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
from ._glob import Globber, no_recurse_symlinks
__all__ = ["UnsupportedOperation"]
@ -119,7 +118,7 @@ class PurePathBase:
'_resolving',
)
parser = ParserBase()
_globber = Globber
_globber = _Globber
def __init__(self, path, *paths):
self._raw_path = self.parser.join(path, *paths) if paths else path
@ -671,7 +670,7 @@ class PathBase(PurePathBase):
# know the case sensitivity of the underlying filesystem, so we
# must use scandir() for everything, including non-wildcard parts.
case_pedantic = True
recursive = True if recurse_symlinks else no_recurse_symlinks
recursive = True if recurse_symlinks else _no_recurse_symlinks
globber = self._globber(self.parser.sep, case_sensitive, case_pedantic, recursive)
return globber.selector(parts)