summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-07 06:49:42 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-07 06:49:42 (GMT)
commitc98b26a6ac0e5e68dd2eb820430cc2a44b4df019 (patch)
tree0ddea857df78ff453787e72ca58be6a88e938293 /Lib
parent1de1a6a2dc5338aed81dd98fe4b5edaddfac6a2d (diff)
downloadcpython-c98b26a6ac0e5e68dd2eb820430cc2a44b4df019.zip
cpython-c98b26a6ac0e5e68dd2eb820430cc2a44b4df019.tar.gz
cpython-c98b26a6ac0e5e68dd2eb820430cc2a44b4df019.tar.bz2
Issue #25596: Falls back to listdir in glob for bytes paths on Windows.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/glob.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/Lib/glob.py b/Lib/glob.py
index 002cd92..7c3cccb 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -118,13 +118,22 @@ def _iterdir(dirname, dironly):
else:
dirname = os.curdir
try:
- with os.scandir(dirname) as it:
- for entry in it:
- try:
- if not dironly or entry.is_dir():
- yield entry.name
- except OSError:
- pass
+ if os.name == 'nt' and isinstance(dirname, bytes):
+ names = os.listdir(dirname)
+ if dironly:
+ for name in names:
+ if os.path.isdir(os.path.join(dirname, name)):
+ yield name
+ else:
+ yield from names
+ else:
+ with os.scandir(dirname) as it:
+ for entry in it:
+ try:
+ if not dironly or entry.is_dir():
+ yield entry.name
+ except OSError:
+ pass
except OSError:
return