diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-06-06 22:49:50 +1000 |
---|---|---|
committer | Jim Mussared <jim.mussared@gmail.com> | 2023-06-08 17:54:24 +1000 |
commit | e6926d60219d9b00da3eedb5eedecefe0d6c321c (patch) | |
tree | 57ea776fc8183c9da99dde966e88947ed914f6ec /py | |
parent | 13c817e61cf2f00fc398e01840e5d8c20e575c8c (diff) | |
download | micropython-e6926d60219d9b00da3eedb5eedecefe0d6c321c.tar.gz micropython-e6926d60219d9b00da3eedb5eedecefe0d6c321c.zip |
py/objmodule: Workaround for MSVC with no module delegation.
When compiling mpy-cross, there is no `sys` module, and so there will
be no entries in the `mp_builtin_module_delegation_table`.
MSVC doesn't like this, so instead pretend as if the feature isn't
enabled at all.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py')
-rw-r--r-- | py/makemoduledefs.py | 3 | ||||
-rw-r--r-- | py/objmodule.c | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py index 5a1362a4c9..b1e118bf37 100644 --- a/py/makemoduledefs.py +++ b/py/makemoduledefs.py @@ -103,6 +103,9 @@ def generate_module_table_header(modules): def generate_module_delegations(delegations): + if not delegations: + return + print("\n#define MICROPY_MODULE_DELEGATIONS \\") for obj_module, fun_name in delegations: print( diff --git a/py/objmodule.c b/py/objmodule.c index ad96a3be28..8ffae139bc 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -230,7 +230,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) { } STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - #if MICROPY_MODULE_ATTR_DELEGATION + #if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS) // Delegate lookup to a module's custom attr method. size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table); for (size_t i = 0; i < n; ++i) { |