summaryrefslogtreecommitdiffstatshomepage
path: root/shared/runtime
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2021-12-11 22:40:21 +1100
committerDamien George <damien@micropython.org>2021-12-18 00:01:59 +1100
commite0bf4611c3a8b23b3c52e6a7804aac341ac3a87d (patch)
treebe1d16834d97297a87768a9e41b0a682b1b33f47 /shared/runtime
parentf853e3e106b151ec2819df729fd68815dce693fb (diff)
downloadmicropython-e0bf4611c3a8b23b3c52e6a7804aac341ac3a87d.tar.gz
micropython-e0bf4611c3a8b23b3c52e6a7804aac341ac3a87d.zip
py: Only search frozen modules when '.frozen' is found in sys.path.
This changes makemanifest.py & mpy-tool.py to merge string and mpy names into the same list (now mp_frozen_names). The various paths for loading a frozen module (mp_find_frozen_module) and checking existence of a frozen module (mp_frozen_stat) use a common function that searches this list. In addition, the frozen lookup will now only take place if the path starts with ".frozen", which needs to be added to sys.path. This fixes issues #1804, #2322, #3509, #6419. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'shared/runtime')
-rw-r--r--shared/runtime/pyexec.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c
index 006ec096f7..2dceb647c3 100644
--- a/shared/runtime/pyexec.c
+++ b/shared/runtime/pyexec.c
@@ -674,7 +674,7 @@ int pyexec_file(const char *filename) {
int pyexec_file_if_exists(const char *filename) {
#if MICROPY_MODULE_FROZEN
- if (mp_frozen_stat(filename) == MP_IMPORT_STAT_FILE) {
+ if (mp_find_frozen_module(filename, NULL, NULL) == MP_IMPORT_STAT_FILE) {
return pyexec_frozen_module(filename);
}
#endif
@@ -687,7 +687,8 @@ int pyexec_file_if_exists(const char *filename) {
#if MICROPY_MODULE_FROZEN
int pyexec_frozen_module(const char *name) {
void *frozen_data;
- int frozen_type = mp_find_frozen_module(name, strlen(name), &frozen_data);
+ int frozen_type;
+ mp_find_frozen_module(name, &frozen_type, &frozen_data);
switch (frozen_type) {
#if MICROPY_MODULE_FROZEN_STR