diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-06-05 15:52:57 +1000 |
---|---|---|
committer | Jim Mussared <jim.mussared@gmail.com> | 2023-06-08 17:54:24 +1000 |
commit | 13c817e61cf2f00fc398e01840e5d8c20e575c8c (patch) | |
tree | 6ee790425d31e5f6642537e2426100e0d1119aa4 /py/makeqstrdefs.py | |
parent | eb85f4d4c9c332c8e7bef9b20bb06e25f6f6c5d2 (diff) | |
download | micropython-13c817e61cf2f00fc398e01840e5d8c20e575c8c.tar.gz micropython-13c817e61cf2f00fc398e01840e5d8c20e575c8c.zip |
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 <jim.mussared@gmail.com>
Diffstat (limited to 'py/makeqstrdefs.py')
-rw-r--r-- | py/makeqstrdefs.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index dd96513351..64249f76ce 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -93,7 +93,9 @@ def process_file(f): elif args.mode == _MODE_COMPRESS: re_match = re.compile(r'MP_COMPRESSED_ROM_TEXT\("([^"]*)"\)') elif args.mode == _MODE_MODULE: - re_match = re.compile(r"MP_REGISTER_(?:EXTENSIBLE_)?MODULE\(.*?,\s*.*?\);") + re_match = re.compile( + r"(?:MP_REGISTER_MODULE|MP_REGISTER_EXTENSIBLE_MODULE|MP_REGISTER_MODULE_DELEGATION)\(.*?,\s*.*?\);" + ) elif args.mode == _MODE_ROOT_POINTER: re_match = re.compile(r"MP_REGISTER_ROOT_POINTER\(.*?\);") output = [] |