Skip to content

Commit e6926d6

Browse files
committed
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>
1 parent 13c817e commit e6926d6

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

py/makemoduledefs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ def generate_module_table_header(modules):
103103

104104

105105
def generate_module_delegations(delegations):
106+
if not delegations:
107+
return
108+
106109
print("\n#define MICROPY_MODULE_DELEGATIONS \\")
107110
for obj_module, fun_name in delegations:
108111
print(

py/objmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
230230
}
231231

232232
STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
233-
#if MICROPY_MODULE_ATTR_DELEGATION
233+
#if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS)
234234
// Delegate lookup to a module's custom attr method.
235235
size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table);
236236
for (size_t i = 0; i < n; ++i) {

0 commit comments

Comments
 (0)