From 13c817e61cf2f00fc398e01840e5d8c20e575c8c Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Mon, 5 Jun 2023 15:52:57 +1000 Subject: py/objmodule: Add a table of built-in modules with delegation. This replaces the previous QSTR_null entry in the globals dict which could leak out to Python (e.g. via iteration of mod.__dict__) and could lead to crashes. It results in smaller code size at the expense of turning a lookup into a loop, but the list it is looping over likely only contains one or two elements. To allow a module to register its custom attr function it can use the new `MP_REGISTER_MODULE_DELEGATION` macro. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- py/objmodule.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'py/objmodule.h') diff --git a/py/objmodule.h b/py/objmodule.h index 63ae3c3bd..9cc9a2f10 100644 --- a/py/objmodule.h +++ b/py/objmodule.h @@ -28,9 +28,6 @@ #include "py/obj.h" -// Place at the very end of a module's globals_table. -#define MP_MODULE_ATTR_DELEGATION_ENTRY(ptr) { MP_ROM_QSTR(MP_QSTRnull), MP_ROM_PTR(ptr) } - extern const mp_map_t mp_builtin_module_map; extern const mp_map_t mp_builtin_extensible_module_map; -- cgit v1.2.3