Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern contains a wildcard in the drive or UNC path.

Patch by Serhiy Storchaka.
This commit is contained in:
Antoine Pitrou 2012-12-16 13:54:14 +01:00
commit 39a6ee20ac
3 changed files with 21 additions and 1 deletions

View file

@ -28,7 +28,10 @@ def iglob(pathname):
if not dirname:
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]