Skip to content

Commit 4072274

Browse files
committed
makeqstrdata: ensure certain qstrs are as early as possible
Some qstrs like those representing binary ops such as __add__ must have qstr numbers that fit in 8 bits. Replace the former ad-hoc method, which sorted *other* dunder-identifiers early with a list of all the qstrs that have this requirement. Before this, the unix coverage build was failing when I added certain qstrs like "<input>" for a codeop filename default value.
1 parent 998cb69 commit 4072274

File tree

1 file changed

+68
-12
lines changed

1 file changed

+68
-12
lines changed

py/makeqstrdata.py

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,73 @@
250250
"zip",
251251
]
252252

253+
# These qstrs have to be sorted early (preferably right after static_qstr_list) because they are required to fit in 8-bit values
254+
# however they should never be *forced* to appear
255+
# repeats len, hash, int from the static qstr list, but this doesn't hurt anything.
256+
eightbit_qstr_list = [
257+
"__abs__",
258+
"__add__",
259+
"__and__",
260+
"__bool__",
261+
"__complex__",
262+
"__contains__",
263+
"__delete__",
264+
"__divmod__",
265+
"__eq__",
266+
"__float__",
267+
"__floordiv__",
268+
"__ge__",
269+
"__get__",
270+
"__gt__",
271+
"__hash__",
272+
"__iadd__",
273+
"__iand__",
274+
"__ifloordiv__",
275+
"__ilshift__",
276+
"__imatmul__",
277+
"__imod__",
278+
"__imul__",
279+
"__int__",
280+
"__invert__",
281+
"__ior__",
282+
"__ipow__",
283+
"__irshift__",
284+
"__isub__",
285+
"__itruediv__",
286+
"__ixor__",
287+
"__le__",
288+
"__len__",
289+
"__lshift__",
290+
"__lt__",
291+
"__matmul__",
292+
"__mod__",
293+
"__mul__",
294+
"__ne__",
295+
"__neg__",
296+
"__or__",
297+
"__pos__",
298+
"__pow__",
299+
"__radd__",
300+
"__rand__",
301+
"__rfloordiv__",
302+
"__rlshift__",
303+
"__rmatmul__",
304+
"__rmod__",
305+
"__rmul__",
306+
"__ror__",
307+
"__rpow__",
308+
"__rrshift__",
309+
"__rshift__",
310+
"__rsub__",
311+
"__rtruediv__",
312+
"__rxor__",
313+
"__set__",
314+
"__sizeof__",
315+
"__sub__",
316+
"__truediv__",
317+
"__xor__",
318+
]
319+
253320

254321
# this must match the equivalent function in qstr.c
255322
def compute_hash(qstr, bytes_hash):
@@ -337,18 +404,7 @@ def parse_input_headers_with_translations(infiles):
337404
order = len(qstrs)
338405
# but put special method names like __add__ at the top of list, so
339406
# that their id's fit into a byte
340-
if ident == "":
341-
# Sort empty qstr above all still
342-
order = -200000
343-
elif ident == "__dir__":
344-
# Put __dir__ after empty qstr for builtin dir() to work
345-
order = -190000
346-
elif ident.startswith("__"):
347-
order -= 100000
348-
# CIRCUITPY-CHANGE
349-
elif ident.startswith("_lt"):
350-
order -= 100000
351-
elif ident.startswith("_gt"):
407+
if ident in eightbit_qstr_list:
352408
order -= 100000
353409
qstrs[ident] = (order, ident, qstr)
354410

0 commit comments

Comments
 (0)