mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py/mpconfig: Rename MICROPY_PY___FILE__ to MICROPY_MODULE___FILE__.
For consistency with other module-related configuration options. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -153,7 +153,7 @@ static mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
|
||||
|
||||
#if MICROPY_MODULE_FROZEN_STR || MICROPY_ENABLE_COMPILER
|
||||
static void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
|
||||
#if MICROPY_PY___FILE__
|
||||
#if MICROPY_MODULE___FILE__
|
||||
qstr source_name = lex->source_name;
|
||||
mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
|
||||
#endif
|
||||
@@ -166,7 +166,7 @@ static void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
|
||||
|
||||
#if (MICROPY_HAS_FILE_READER && MICROPY_PERSISTENT_CODE_LOAD) || MICROPY_MODULE_FROZEN_MPY
|
||||
static void do_execute_proto_fun(const mp_module_context_t *context, mp_proto_fun_t proto_fun, qstr source_name) {
|
||||
#if MICROPY_PY___FILE__
|
||||
#if MICROPY_MODULE___FILE__
|
||||
mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
|
||||
#else
|
||||
(void)source_name;
|
||||
@@ -225,7 +225,7 @@ static void do_load(mp_module_context_t *module_obj, vstr_t *file) {
|
||||
if (frozen_type == MP_FROZEN_MPY) {
|
||||
const mp_frozen_module_t *frozen = modref;
|
||||
module_obj->constants = frozen->constants;
|
||||
#if MICROPY_PY___FILE__
|
||||
#if MICROPY_MODULE___FILE__
|
||||
qstr frozen_file_qstr = qstr_from_str(file_str + frozen_path_prefix_len);
|
||||
#else
|
||||
qstr frozen_file_qstr = MP_QSTRnull;
|
||||
|
||||
@@ -990,6 +990,11 @@ typedef time_t mp_timestamp_t;
|
||||
#define MICROPY_STREAMS_POSIX_API (0)
|
||||
#endif
|
||||
|
||||
// Whether to set __file__ on imported modules.
|
||||
#ifndef MICROPY_MODULE___FILE__
|
||||
#define MICROPY_MODULE___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
|
||||
#endif
|
||||
|
||||
// Whether modules can use MP_REGISTER_MODULE_DELEGATION() to delegate failed
|
||||
// attribute lookups to a custom handler function.
|
||||
#ifndef MICROPY_MODULE_ATTR_DELEGATION
|
||||
@@ -1422,11 +1427,6 @@ typedef time_t mp_timestamp_t;
|
||||
#define MICROPY_PY_BUILTINS_HELP_MODULES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
|
||||
#endif
|
||||
|
||||
// Whether to set __file__ for imported modules
|
||||
#ifndef MICROPY_PY___FILE__
|
||||
#define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
|
||||
#endif
|
||||
|
||||
// Whether to process __all__ when importing all public symbols from module
|
||||
#ifndef MICROPY_MODULE___ALL__
|
||||
#define MICROPY_MODULE___ALL__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES)
|
||||
|
||||
@@ -44,7 +44,7 @@ static void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin
|
||||
module_name = mp_obj_str_get_str(elem->value);
|
||||
}
|
||||
|
||||
#if MICROPY_PY___FILE__
|
||||
#if MICROPY_MODULE___FILE__
|
||||
// If we store __file__ to imported modules then try to lookup this
|
||||
// symbol to give more information about the module.
|
||||
elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___file__), MP_MAP_LOOKUP);
|
||||
|
||||
Reference in New Issue
Block a user