mirror of
https://github.com/micropython/micropython.git
synced 2025-12-15 17:30:14 +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:
@@ -81,7 +81,7 @@ static int compile_and_save(const char *file, const char *output_file, const cha
|
||||
source_name = qstr_from_str(source_file);
|
||||
}
|
||||
|
||||
#if MICROPY_PY___FILE__
|
||||
#if MICROPY_MODULE___FILE__
|
||||
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
|
||||
#endif
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
#define MICROPY_GCREGS_SETJMP (1)
|
||||
#endif
|
||||
|
||||
#define MICROPY_PY___FILE__ (0)
|
||||
#define MICROPY_MODULE___FILE__ (0)
|
||||
#define MICROPY_PY_ARRAY (0)
|
||||
#define MICROPY_PY_ATTRTUPLE (0)
|
||||
#define MICROPY_PY_COLLECTIONS (0)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#define MICROPY_OPT_MATH_FACTORIAL (0)
|
||||
#define MICROPY_REPL_EMACS_KEYS (0)
|
||||
#define MICROPY_PY_BUILTINS_COMPLEX (0)
|
||||
#define MICROPY_MODULE___FILE__ (0)
|
||||
#define MICROPY_PY_DELATTR_SETATTR (0)
|
||||
#define MICROPY_PY_BUILTINS_STR_CENTER (0)
|
||||
#define MICROPY_PY_BUILTINS_STR_PARTITION (0)
|
||||
@@ -32,7 +33,6 @@
|
||||
#define MICROPY_PY_BUILTINS_EXECFILE (0)
|
||||
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
|
||||
#define MICROPY_PY_BUILTINS_POW3 (0)
|
||||
#define MICROPY_PY___FILE__ (0)
|
||||
#define MICROPY_PY_MATH_CONSTANTS (0)
|
||||
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
|
||||
#define MICROPY_PY_MATH_FACTORIAL (0)
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
#define MICROPY_ERROR_REPORTING (2)
|
||||
#define MICROPY_FULL_CHECKS (1)
|
||||
#define MICROPY_GC_ALLOC_THRESHOLD (1)
|
||||
#define MICROPY_MODULE___FILE__ (1)
|
||||
#define MICROPY_MODULE_GETATTR (1)
|
||||
#define MICROPY_MULTIPLE_INHERITANCE (1)
|
||||
#define MICROPY_PY_ARRAY (1)
|
||||
@@ -290,7 +291,6 @@
|
||||
#define MICROPY_PY_STRUCT (1)
|
||||
#define MICROPY_PY_SYS (1)
|
||||
#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (1)
|
||||
#define MICROPY_PY___FILE__ (1)
|
||||
#endif
|
||||
|
||||
#ifndef MICROPY_PY_UBLUEPY
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#define MICROPY_ENABLE_SOURCE_LINE (0)
|
||||
#define MICROPY_ENABLE_DOC_STRING (0)
|
||||
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
|
||||
#define MICROPY_MODULE___FILE__ (0)
|
||||
#define MICROPY_PY_ASYNC_AWAIT (0)
|
||||
#define MICROPY_PY_BUILTINS_BYTEARRAY (0)
|
||||
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
|
||||
@@ -51,7 +52,6 @@
|
||||
#define MICROPY_PY_BUILTINS_SLICE (0)
|
||||
#define MICROPY_PY_BUILTINS_PROPERTY (0)
|
||||
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
||||
#define MICROPY_PY___FILE__ (0)
|
||||
#define MICROPY_PY_GC (1)
|
||||
#define MICROPY_PY_ARRAY (0)
|
||||
#define MICROPY_PY_COLLECTIONS (0)
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
|
||||
#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0)
|
||||
#define MICROPY_PY_ASYNC_AWAIT (0)
|
||||
#define MICROPY_MODULE___FILE__ (0)
|
||||
#define MICROPY_MODULE_BUILTIN_INIT (1)
|
||||
#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
|
||||
#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1)
|
||||
@@ -73,7 +74,6 @@
|
||||
#define MICROPY_PY_BUILTINS_STR_OP_MODULO (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
|
||||
#define MICROPY_PY___FILE__ (0)
|
||||
#define MICROPY_PY_GC (1)
|
||||
#define MICROPY_PY_ARRAY (1)
|
||||
#define MICROPY_PY_COLLECTIONS (1)
|
||||
|
||||
@@ -139,7 +139,7 @@ static int execute_from_lexer(int source_kind, const void *source, mp_parse_inpu
|
||||
|
||||
qstr source_name = lex->source_name;
|
||||
|
||||
#if MICROPY_PY___FILE__
|
||||
#if MICROPY_MODULE___FILE__
|
||||
if (input_kind == MP_PARSE_FILE_INPUT) {
|
||||
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
|
||||
}
|
||||
|
||||
@@ -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