diff options
| author | Scott Shawcroft <scott@chickadee.tech> | 2017-08-10 15:46:17 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@chickadee.tech> | 2017-08-10 15:46:17 -0700 |
| commit | f6a702538a0b3dd72879d65e3acc32520d4371f5 (patch) | |
| tree | 9458c2136d681a962dbc88c2ab592404abafcc18 /py/builtinimport.c | |
| parent | 5c32a5aa6a9ab207235db340576bdc6a8ed81225 (diff) | |
py: Pretend frozen files are stored under .frozen rather than the empty path.
This makes it clear when frozen modules are loaded as opposed to the empty path
which represents the current working directory. Furthermore, by splitting the two
apart this allows one to control in what order frozen modules are loaded.
This is a prerequisite for #56.
Diffstat (limited to 'py/builtinimport.c')
| -rw-r--r-- | py/builtinimport.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c index 48aee58d1..01dddd02b 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -57,9 +57,11 @@ bool mp_obj_is_package(mp_obj_t module) { // (whatever is available, if at all). STATIC mp_import_stat_t mp_import_stat_any(const char *path) { #if MICROPY_MODULE_FROZEN - mp_import_stat_t st = mp_frozen_stat(path); - if (st != MP_IMPORT_STAT_NO_EXIST) { - return st; + if (strlen(path) > 8 && strncmp(".frozen/", path, 8) == 0) { + mp_import_stat_t st = mp_frozen_stat(path + 8); + if (st != MP_IMPORT_STAT_NO_EXIST) { + return st; + } } #endif return mp_import_stat(path); |
