summaryrefslogtreecommitdiffstatshomepage
path: root/py/makeqstrdata.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2024-03-26 15:23:21 +1100
committerDamien George <damien@micropython.org>2024-03-26 22:52:25 +1100
commitd694ac6e1b316ad3aaed2589eb261a52aa6e22c9 (patch)
tree58743bcb02e05fa89c3eb4d6893429ea5aee5ee3 /py/makeqstrdata.py
parent57de9da35233b4120a00386c52485e68bbc931fb (diff)
downloadmicropython-d694ac6e1b316ad3aaed2589eb261a52aa6e22c9.tar.gz
micropython-d694ac6e1b316ad3aaed2589eb261a52aa6e22c9.zip
py/makeqstrdata.py: Ensure that scope names get low qstr values.
Originally implemented in a patch file provided by @ironss-iotec. Fixes issue #14093. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/makeqstrdata.py')
-rw-r--r--py/makeqstrdata.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py
index 3e5e7930a5..480344180a 100644
--- a/py/makeqstrdata.py
+++ b/py/makeqstrdata.py
@@ -223,11 +223,11 @@ static_qstr_list = [
"zip",
]
-# Additional QSTRs that must have index <255 because they are stored in
-# `mp_binary_op_method_name` and `mp_unary_op_method_name` (see py/objtype.c).
+# Additional QSTRs that must have index <255 because they are stored as `byte` values.
# These are not part of the .mpy compatibility list, but we place them in the
# fixed unsorted pool (i.e. QDEF0) to ensure their indices are small.
-operator_qstr_list = {
+unsorted_qstr_list = {
+ # From py/objtype.c: used in the `mp_binary_op_method_name` and `mp_unary_op_method_name` tables.
"__bool__",
"__pos__",
"__neg__",
@@ -286,6 +286,13 @@ operator_qstr_list = {
"__get__",
"__set__",
"__delete__",
+ # From py/scope.c: used in `scope_simple_name_table` table.
+ # Note: "<module>" is already in `static_qstr_list`.
+ "<lambda>",
+ "<listcomp>",
+ "<dictcomp>",
+ "<setcomp>",
+ "<genexpr>",
}
@@ -404,10 +411,10 @@ def print_qstr_data(qcfgs, qstrs):
print("QDEF0(MP_QSTR_%s, %s)" % (qstr_escape(qstr), qbytes))
# add remaining qstrs to the sorted (by value) pool (unless they're in
- # operator_qstr_list, in which case add them to the unsorted pool)
+ # unsorted_qstr_list, in which case add them to the unsorted pool)
for ident, qstr in sorted(qstrs.values(), key=lambda x: x[1]):
qbytes = make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr)
- pool = 0 if qstr in operator_qstr_list else 1
+ pool = 0 if qstr in unsorted_qstr_list else 1
print("QDEF%d(MP_QSTR_%s, %s)" % (pool, ident, qbytes))