py: Only load frozen modules when the filename has the prefix. (#235)
* py: Only load frozen modules when the filename has the prefix. This allows one to override a built-in module by loading a newer version onto the file system. * Unbreak mpys
This commit is contained in:
parent
f9c54665f7
commit
6baacf46b7
@ -190,11 +190,15 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {
|
||||
char *file_str = vstr_null_terminated_str(file);
|
||||
#endif
|
||||
|
||||
#if MICROPY_MODULE_FROZEN || MICROPY_MODULE_FROZEN_MPY
|
||||
if (strncmp(MP_FROZEN_FAKE_DIR_SLASH,
|
||||
file_str,
|
||||
MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) {
|
||||
// If we support frozen modules (either as str or mpy) then try to find the
|
||||
// requested filename in the list of frozen module filenames.
|
||||
#if MICROPY_MODULE_FROZEN
|
||||
void *modref;
|
||||
int frozen_type = mp_find_frozen_module(file_str, file->len, &modref);
|
||||
int frozen_type = mp_find_frozen_module(file_str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH, file->len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH, &modref);
|
||||
#endif
|
||||
|
||||
// If we support frozen str modules and the compiler is enabled, and we
|
||||
@ -215,6 +219,9 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif // MICROPY_MODULE_FROZEN || MICROPY_MODULE_FROZEN_MPY
|
||||
|
||||
// If we support loading .mpy files then check if the file extension is of
|
||||
// the correct format and, if so, load and execute the file.
|
||||
#if MICROPY_PERSISTENT_CODE_LOAD
|
||||
|
Loading…
Reference in New Issue
Block a user