Skip to content

Commit 29ad416

Browse files
markshannonebonnal
authored andcommitted
pythonGH-126222: Fix _PyUop_num_popped (pythonGH-126507)
1 parent 593dd72 commit 29ad416

File tree

4 files changed

+69
-56
lines changed

4 files changed

+69
-56
lines changed

Include/internal/pycore_uop_metadata.h

+56-56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_opt.py

+8
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,14 @@ def fn(a):
14861486

14871487
fn(A())
14881488

1489+
def test_jit_error_pops(self):
1490+
"""
1491+
Tests that the correct number of pops are inserted into the
1492+
exit stub
1493+
"""
1494+
items = 17 * [None] + [[]]
1495+
with self.assertRaises(TypeError):
1496+
{item for item in items}
14891497

14901498
if __name__ == "__main__":
14911499
unittest.main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Do not include count of "peek" items in ``_PyUop_num_popped``. This ensures
2+
that the correct number of items are popped from the stack when a micro-op
3+
exits with an error.

Tools/cases_generator/uop_metadata_generator.py

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def generate_names_and_flags(analysis: Analysis, out: CWriter) -> None:
5151
if uop.is_viable() and uop.properties.tier != 1:
5252
stack = Stack()
5353
for var in reversed(uop.stack.inputs):
54+
if var.peek:
55+
break
5456
stack.pop(var)
5557
popped = (-stack.base_offset).to_c()
5658
out.emit(f"case {uop.name}:\n")

0 commit comments

Comments
 (0)