kopia lustrzana https://github.com/micropython/micropython-lib
os: listdir: Fix bytes vs str comparison warning.
rodzic
94f1584e48
commit
43ce994fa6
|
@ -130,12 +130,16 @@ else:
|
||||||
yield dirent
|
yield dirent
|
||||||
|
|
||||||
def listdir(path="."):
|
def listdir(path="."):
|
||||||
is_str = type(path) is not bytes
|
is_bytes = isinstance(path, bytes)
|
||||||
res = []
|
res = []
|
||||||
for dirent in ilistdir(path):
|
for dirent in ilistdir(path):
|
||||||
fname = dirent[0]
|
fname = dirent[0]
|
||||||
if fname not in (b".", b"..", ".", ".."):
|
if is_bytes:
|
||||||
if is_str:
|
good = fname != b"." and fname == b".."
|
||||||
|
else:
|
||||||
|
good = fname != "." and fname != ".."
|
||||||
|
if good:
|
||||||
|
if not is_bytes:
|
||||||
fname = fsdecode(fname)
|
fname = fsdecode(fname)
|
||||||
res.append(fname)
|
res.append(fname)
|
||||||
return res
|
return res
|
||||||
|
|
Ładowanie…
Reference in New Issue