aboutsummaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
authorScott Shawcroft <scott@chickadee.tech>2017-08-10 15:46:17 -0700
committerScott Shawcroft <scott@chickadee.tech>2017-08-10 15:46:17 -0700
commitf6a702538a0b3dd72879d65e3acc32520d4371f5 (patch)
tree9458c2136d681a962dbc88c2ab592404abafcc18 /unix
parent5c32a5aa6a9ab207235db340576bdc6a8ed81225 (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 'unix')
-rw-r--r--unix/main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/unix/main.c b/unix/main.c
index 633144c86..e96cdaaa2 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -453,7 +453,9 @@ MP_NOINLINE int main_(int argc, char **argv) {
path = "~/.micropython/lib:/usr/lib/micropython";
#endif
}
- size_t path_num = 1; // [0] is for current dir (or base dir of the script)
+ size_t path_num = 2; // [0] is for current dir (or base dir of the script)
+ // [1] is for frozen files.
+ size_t builtin_path_count = path_num;
if (*path == ':') {
path_num++;
}
@@ -467,9 +469,10 @@ MP_NOINLINE int main_(int argc, char **argv) {
mp_obj_t *path_items;
mp_obj_list_get(mp_sys_path, &path_num, &path_items);
path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_);
+ path_items[1] = MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen);
{
char *p = path;
- for (mp_uint_t i = 1; i < path_num; i++) {
+ for (mp_uint_t i = builtin_path_count; i < path_num; i++) {
char *p1 = strchr(p, PATHLIST_SEP_CHAR);
if (p1 == NULL) {
p1 = p + strlen(p);