cpython: 4532c4f37429 (original) (raw)

--- a/Lib/glob.py +++ b/Lib/glob.py @@ -30,6 +30,13 @@ def iglob(pathname, *, recursive=False): If recursive is true, the pattern '**' will match any files and zero or more directories and subdirectories. """

+ +def _iglob(pathname, recursive): dirname, basename = os.path.split(pathname) if not has_magic(pathname): if basename: @@ -50,7 +57,7 @@ def iglob(pathname, *, recursive=False): # drive or UNC path. Prevent an infinite recursion if a drive or UNC path # contains magic characters (i.e. r'\?\C:'). if dirname != pathname and has_magic(dirname):

Recursively yields relative pathnames inside a literal directory.

- def _rlistdir(dirname): if not dirname: if isinstance(dirname, bytes):

--- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -31,6 +31,7 @@ class GlobTests(unittest.TestCase): self.mktemp('.bb', 'H') self.mktemp('aaa', 'zzzF') self.mktemp('ZZZ')

@@ -200,7 +201,7 @@ class GlobTests(unittest.TestCase): def test_recursive_glob(self): eq = self.assertSequencesEqual_noorder

@@ -217,8 +218,8 @@ class GlobTests(unittest.TestCase): ('sym3', 'efg', 'ha'), ] eq(self.rglob('**'), self.joins(('',), *full))

@@ -229,11 +230,11 @@ class GlobTests(unittest.TestCase): ('a', ''), ('a', 'D'), ('a', 'bcd'), ('a', 'bcd', 'EF'), ('a', 'bcd', 'efg'), ('a', 'bcd', 'efg', 'ha'))) eq(self.rglob('a**'), self.joins(('a',), ('aaa',), ('aab',)))

@@ -247,10 +248,18 @@ class GlobTests(unittest.TestCase): eq(glob.glob('**', recursive=True), [join(*i) for i in full]) eq(glob.glob(join('**', ''), recursive=True), [join(*i) for i in dirs])

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -61,6 +61,8 @@ Core and Builtins Library ------- +- Issue #25584: Fixed recursive glob() with patterns starting with '**'. +