Commit c98b26a6 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #25596: Falls back to listdir in glob for bytes paths on Windows.

parent 1de1a6a2
...@@ -118,13 +118,22 @@ def _iterdir(dirname, dironly): ...@@ -118,13 +118,22 @@ def _iterdir(dirname, dironly):
else: else:
dirname = os.curdir dirname = os.curdir
try: try:
with os.scandir(dirname) as it: if os.name == 'nt' and isinstance(dirname, bytes):
for entry in it: names = os.listdir(dirname)
try: if dironly:
if not dironly or entry.is_dir(): for name in names:
yield entry.name if os.path.isdir(os.path.join(dirname, name)):
except OSError: yield name
pass 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: except OSError:
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment