From 327b0f76dac55a4bfe5df52799f72734623a351a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 15 Jun 2018 10:51:03 -0400 Subject: [PATCH] fix os.listdir() when current dir is '/' --- shared-bindings/os/__init__.c | 2 +- shared-module/os/__init__.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 159f5448a0f08..1b8831afa5bfe 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -87,7 +87,7 @@ mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) { if (n_args == 1) { path = mp_obj_str_get_str(args[0]); } else { - path = ""; + path = mp_obj_str_get_str(common_hal_os_getcwd()); } return common_hal_os_listdir(path); } diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index 9eb04e2818cfb..1dadd254aa78e 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -103,7 +103,7 @@ mp_obj_t common_hal_os_listdir(const char* path) { iter.base.type = &mp_type_polymorph_iter; iter.iternext = mp_vfs_ilistdir_it_iternext; iter.cur.vfs = MP_STATE_VM(vfs_mount_table); - iter.is_str = mp_obj_get_type(path) == &mp_type_str; + iter.is_str = true; iter.is_iter = false; } else { iter_obj = mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &path_out);