os: listdir: Fix bytes vs str comparison warning.

pull/143/merge
Paul Sokolovsky 2017-04-29 19:39:26 +03:00
rodzic 94f1584e48
commit 43ce994fa6
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -130,12 +130,16 @@ else:
yield dirent
def listdir(path="."):
is_str = type(path) is not bytes
is_bytes = isinstance(path, bytes)
res = []
for dirent in ilistdir(path):
fname = dirent[0]
if fname not in (b".", b"..", ".", ".."):
if is_str:
if is_bytes:
good = fname != b"." and fname == b".."
else:
good = fname != "." and fname != ".."
if good:
if not is_bytes:
fname = fsdecode(fname)
res.append(fname)
return res