Commit 19b992a8 authored by Damien George's avatar Damien George
Browse files

Merge branch 'master' of github.com:micropython/micropython

parents b96c7c03 42453dc9
...@@ -218,6 +218,7 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) { ...@@ -218,6 +218,7 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
if (stat == MP_IMPORT_STAT_DIR) { if (stat == MP_IMPORT_STAT_DIR) {
DEBUG_printf("%s is dir\n", vstr_str(&path)); DEBUG_printf("%s is dir\n", vstr_str(&path));
mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str((byte*)vstr_str(&path), vstr_len(&path), false));
vstr_add_char(&path, PATH_SEP_CHAR); vstr_add_char(&path, PATH_SEP_CHAR);
vstr_add_str(&path, "__init__.py"); vstr_add_str(&path, "__init__.py");
if (mp_import_stat(vstr_str(&path)) != MP_IMPORT_STAT_FILE) { 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) { ...@@ -230,7 +231,6 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
vstr_cut_tail_bytes(&path, sizeof("/__init__.py") - 1); // cut off /__init__.py vstr_cut_tail_bytes(&path, sizeof("/__init__.py") - 1); // cut off /__init__.py
// https://docs.python.org/3.3/reference/import.html // https://docs.python.org/3.3/reference/import.html
// "Specifically, any module that contains a __path__ attribute is considered a package." // "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 } else { // MP_IMPORT_STAT_FILE
do_load(module_obj, &path); do_load(module_obj, &path);
// TODO: We cannot just break here, at the very least, we must execute // TODO: We cannot just break here, at the very least, we must execute
......
...@@ -1050,7 +1050,7 @@ mp_obj_t mp_import_from(mp_obj_t module, qstr name) { ...@@ -1050,7 +1050,7 @@ mp_obj_t mp_import_from(mp_obj_t module, qstr name) {
if (dest[1] != MP_OBJ_NULL) { if (dest[1] != MP_OBJ_NULL) {
// Hopefully we can't import bound method from an object // Hopefully we can't import bound method from an object
import_error: import_error:
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "Cannot import name '%s'", qstr_str(name))); nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "cannot import name %s", qstr_str(name)));
} }
if (dest[0] != MP_OBJ_NULL) { if (dest[0] != MP_OBJ_NULL) {
...@@ -1078,7 +1078,7 @@ import_error: ...@@ -1078,7 +1078,7 @@ import_error:
args[1] = mp_const_none; // TODO should be globals args[1] = mp_const_none; // TODO should be globals
args[2] = mp_const_none; // TODO should be locals args[2] = mp_const_none; // TODO should be locals
args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module
args[4] = 0; args[4] = MP_OBJ_NEW_SMALL_INT(0);
// TODO lookup __import__ and call that instead of going straight to builtin implementation // TODO lookup __import__ and call that instead of going straight to builtin implementation
return mp_builtin___import__(5, args); return mp_builtin___import__(5, args);
......
# Testing that "recursive" imports (pkg2/__init__.py imports from pkg2) work
import pkg2
from pkg2 import mod1
from pkg2 import mod2
...@@ -77,7 +77,7 @@ void gc_collect(void) { ...@@ -77,7 +77,7 @@ void gc_collect(void) {
//gc_dump_info(); //gc_dump_info();
gc_collect_start(); gc_collect_start();
// this traces .data and .bss sections // this traces the .bss section
#ifdef __CYGWIN__ #ifdef __CYGWIN__
#define BSS_START __bss_start__ #define BSS_START __bss_start__
#else #else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment