Skip to content

Commit a1aaf9a

Browse files
committed
pythonGH-93516: match logic of codeobject.c in _co_firsttraceable calculation
1 parent 42429d3 commit a1aaf9a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Tools/build/deepfreeze.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,12 @@ def generate_code(self, name: str, code: types.CodeType) -> str:
297297
self.write(f".co_linetable = {co_linetable},")
298298
self.write(f"._co_cached = NULL,")
299299
self.write(f".co_code_adaptive = {co_code_adaptive},")
300-
for i, op in enumerate(code.co_code[::2]):
300+
first_traceable = 0
301+
for op in code.co_code[::2]:
301302
if op == RESUME:
302-
self.write(f"._co_firsttraceable = {i},")
303303
break
304+
first_traceable += 1
305+
self.write(f"._co_firsttraceable = {first_traceable},")
304306
name_as_code = f"(PyCodeObject *)&{name}"
305307
self.finis.append(f"_PyStaticCode_Fini({name_as_code});")
306308
self.inits.append(f"_PyStaticCode_Init({name_as_code})")

0 commit comments

Comments
 (0)