Skip to content

Commit 538f020

Browse files
committed
objmodule: Eliminate "bool extensible" param when possible.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
1 parent 0e4bcee commit 538f020

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

py/objmodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,11 @@ static const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] =
174174

175175
// Attempts to find (and initialise) a built-in, otherwise returns
176176
// MP_OBJ_NULL.
177-
mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
177+
mp_obj_t mp_module_get_builtin_impl(qstr module_name
178178
#if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
179+
, bool extensible
180+
#endif
181+
) {
179182

180183
#if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
181184
const mp_map_t *map = extensible ? &mp_builtin_extensible_module_map : &mp_builtin_module_map;

py/objmodule.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ extern const mp_map_t mp_builtin_module_map;
4040
extern const mp_map_t mp_builtin_extensible_module_map;
4141
#endif
4242

43-
mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible);
44-
43+
#if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
44+
mp_obj_t mp_module_get_builtin_impl(qstr module_name, bool extensible);
45+
#define mp_module_get_builtin(module_name, extensible) mp_module_get_builtin_impl((module_name), (extensible))
46+
#else
47+
mp_obj_t mp_module_get_builtin_impl(qstr module_name);
48+
#define mp_module_get_builtin(module_name, extensible) ( \
49+
MP_STATIC_ASSERT(!extensible), mp_module_get_builtin_impl((module_name)) \
50+
)
51+
#endif
4552
void mp_module_generic_attr(qstr attr, mp_obj_t *dest, const uint16_t *keys, mp_obj_t *values);
4653

4754
#endif // MICROPY_INCLUDED_PY_OBJMODULE_H

0 commit comments

Comments
 (0)