summaryrefslogtreecommitdiffstats
path: root/Lib/glob.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-12-16 12:54:14 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-12-16 12:54:14 (GMT)
commit39a6ee20ac5f353a6b8204864d9491deb997ef88 (patch)
tree976c0abc2e1a9edf4c55f65bd913739d8f10ef79 /Lib/glob.py
parent09bc642153fc1b601909fd27d5bd728b9842fa98 (diff)
parent3c331bb729b78419da455b9f8be81b566cb7a489 (diff)
downloadcpython-39a6ee20ac5f353a6b8204864d9491deb997ef88.zip
cpython-39a6ee20ac5f353a6b8204864d9491deb997ef88.tar.gz
cpython-39a6ee20ac5f353a6b8204864d9491deb997ef88.tar.bz2
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.
Diffstat (limited to 'Lib/glob.py')
-rw-r--r--Lib/glob.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/glob.py b/Lib/glob.py
index 3431a69..00f867f 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -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]