]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern conta...
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 16 Dec 2012 12:54:14 +0000 (13:54 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 16 Dec 2012 12:54:14 +0000 (13:54 +0100)
Patch by Serhiy Storchaka.

1  2 
Lib/glob.py
Misc/NEWS

diff --cc Lib/glob.py
index 3431a695bbe2f5d3043b51ee04adac086d5b5030,7279244aa9ab2735f2bc47829fc3f62af9327eff..00f867f8ad4a648366e72a3b653cceb480c3ecdb
@@@ -26,9 -26,13 +26,12 @@@ def iglob(pathname)
          return
      dirname, basename = os.path.split(pathname)
      if not dirname:
 -        for name in glob1(None, basename):
 -            yield name
 +        yield from glob1(None, basename)
          return
-     if has_magic(dirname):
+     # `os.path.split()` returns the argument itself as a dirname if it is a
+     # 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):
          dirs = iglob(dirname)
      else:
          dirs = [dirname]
diff --cc Misc/NEWS
Simple merge