Skip to content

Commit

Permalink
pythonGH-126222: Fix _PyUop_num_popped (pythonGH-126507)
Browse files Browse the repository at this point in the history
  • Loading branch information
markshannon authored Nov 7, 2024
1 parent c9cda16 commit 85036c8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 56 deletions.
112 changes: 56 additions & 56 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,14 @@ def fn(a):

fn(A())

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

if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Do not include count of "peek" items in ``_PyUop_num_popped``. This ensures
that the correct number of items are popped from the stack when a micro-op
exits with an error.
2 changes: 2 additions & 0 deletions Tools/cases_generator/uop_metadata_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def generate_names_and_flags(analysis: Analysis, out: CWriter) -> None:
if uop.is_viable() and uop.properties.tier != 1:
stack = Stack()
for var in reversed(uop.stack.inputs):
if var.peek:
break
stack.pop(var)
popped = (-stack.base_offset).to_c()
out.emit(f"case {uop.name}:\n")
Expand Down

0 comments on commit 85036c8

Please sign in to comment.