summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/builtinimport.c3
-rw-r--r--py/qstrdefs.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index f7c5e4a1eb..501ced7644 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -228,6 +228,9 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
}
do_load(module_obj, &path);
vstr_cut_tail_bytes(&path, sizeof("/__init__.py") - 1); // cut off /__init__.py
+ // https://docs.python.org/3.3/reference/import.html
+ // "Specifically, any module that contains a __path__ attribute is considered a package."
+ mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str((byte*)vstr_str(&path), vstr_len(&path), false));
} else { // MP_IMPORT_STAT_FILE
do_load(module_obj, &path);
// TODO: We cannot just break here, at the very least, we must execute
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index eb72fd265f..d52b870e65 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -13,6 +13,7 @@ Q(__module__)
Q(__name__)
Q(__next__)
Q(__qualname__)
+Q(__path__)
Q(__repl_print__)
Q(__bool__)