From: Antoine Pitrou Date: Sun, 16 Dec 2012 12:54:14 +0000 (+0100) Subject: Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern conta... X-Git-Tag: v3.4.0a1~1844 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39a6ee20ac5f353a6b8204864d9491deb997ef88;p=thirdparty%2FPython%2Fcpython.git 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. --- 39a6ee20ac5f353a6b8204864d9491deb997ef88 diff --cc Lib/glob.py index 3431a695bbe2,7279244aa9ab..00f867f8ad4a --- a/Lib/glob.py +++ b/Lib/glob.py @@@ -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]