Skip to content

Commit 19b992a

Browse files
committed
Merge branch 'master' of github.com:micropython/micropython
2 parents b96c7c0 + 42453dc commit 19b992a

7 files changed

Lines changed: 9 additions & 4 deletions

File tree

py/builtinimport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
218218

219219
if (stat == MP_IMPORT_STAT_DIR) {
220220
DEBUG_printf("%s is dir\n", vstr_str(&path));
221+
mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str((byte*)vstr_str(&path), vstr_len(&path), false));
221222
vstr_add_char(&path, PATH_SEP_CHAR);
222223
vstr_add_str(&path, "__init__.py");
223224
if (mp_import_stat(vstr_str(&path)) != MP_IMPORT_STAT_FILE) {
@@ -230,7 +231,6 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
230231
vstr_cut_tail_bytes(&path, sizeof("/__init__.py") - 1); // cut off /__init__.py
231232
// https://docs.python.org/3.3/reference/import.html
232233
// "Specifically, any module that contains a __path__ attribute is considered a package."
233-
mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str((byte*)vstr_str(&path), vstr_len(&path), false));
234234
} else { // MP_IMPORT_STAT_FILE
235235
do_load(module_obj, &path);
236236
// TODO: We cannot just break here, at the very least, we must execute

py/runtime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ mp_obj_t mp_import_from(mp_obj_t module, qstr name) {
10501050
if (dest[1] != MP_OBJ_NULL) {
10511051
// Hopefully we can't import bound method from an object
10521052
import_error:
1053-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "Cannot import name '%s'", qstr_str(name)));
1053+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "cannot import name %s", qstr_str(name)));
10541054
}
10551055

10561056
if (dest[0] != MP_OBJ_NULL) {
@@ -1078,7 +1078,7 @@ mp_obj_t mp_import_from(mp_obj_t module, qstr name) {
10781078
args[1] = mp_const_none; // TODO should be globals
10791079
args[2] = mp_const_none; // TODO should be locals
10801080
args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module
1081-
args[4] = 0;
1081+
args[4] = MP_OBJ_NEW_SMALL_INT(0);
10821082

10831083
// TODO lookup __import__ and call that instead of going straight to builtin implementation
10841084
return mp_builtin___import__(5, args);

tests/basics/import-pkg4.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Testing that "recursive" imports (pkg2/__init__.py imports from pkg2) work
2+
import pkg2

tests/basics/pkg2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from pkg2 import mod1

tests/basics/pkg2/mod1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from pkg2 import mod2

tests/basics/pkg2/mod2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("in mod2")

unix/gccollect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void gc_collect(void) {
7777
//gc_dump_info();
7878

7979
gc_collect_start();
80-
// this traces .data and .bss sections
80+
// this traces the .bss section
8181
#ifdef __CYGWIN__
8282
#define BSS_START __bss_start__
8383
#else

0 commit comments

Comments
 (0)