https://github.com/python/cpython/commit/b9c693dcca01537eee1ef716ffebc632be37594b
commit: b9c693dcca01537eee1ef716ffebc632be37594b
branch: main
author: Mark Shannon <[email protected]>
committer: markshannon <[email protected]>
date: 2025-01-06T14:16:22Z
summary:

GH-128073: Include `EXIT_IF` when checking for escaping calls (GH-128537)

files:
M Lib/test/test_generated_cases.py
M Tools/cases_generator/analyzer.py

diff --git a/Lib/test/test_generated_cases.py b/Lib/test/test_generated_cases.py
index 9c65e81dfe4be1..75cbd8dd94e9cb 100644
--- a/Lib/test/test_generated_cases.py
+++ b/Lib/test/test_generated_cases.py
@@ -1713,6 +1713,31 @@ def test_pop_dead_inputs_with_output(self):
         """
         self.run_cases_test(input, output)
 
+    def test_no_escaping_calls_in_branching_macros(self):
+
+        input = """
+        inst(OP, ( -- )) {
+            DEOPT_IF(escaping_call());
+        }
+        """
+        with self.assertRaises(SyntaxError):
+            self.run_cases_test(input, "")
+
+        input = """
+        inst(OP, ( -- )) {
+            EXIT_IF(escaping_call());
+        }
+        """
+        with self.assertRaises(SyntaxError):
+            self.run_cases_test(input, "")
+
+        input = """
+        inst(OP, ( -- )) {
+            ERROR_IF(escaping_call(), error);
+        }
+        """
+        with self.assertRaises(SyntaxError):
+            self.run_cases_test(input, "")
 
 class TestGeneratedAbstractCases(unittest.TestCase):
     def setUp(self) -> None:
diff --git a/Tools/cases_generator/analyzer.py 
b/Tools/cases_generator/analyzer.py
index eca851e6de87ae..73c871759afbf5 100644
--- a/Tools/cases_generator/analyzer.py
+++ b/Tools/cases_generator/analyzer.py
@@ -668,7 +668,7 @@ def check_escaping_calls(instr: parser.InstDef, escapes: 
dict[lexer.Token, tuple
         if tkn.kind == "IF":
             next(tkn_iter)
             in_if = 1
-        if tkn.kind == "IDENTIFIER" and tkn.text in ("DEOPT_IF", "ERROR_IF"):
+        if tkn.kind == "IDENTIFIER" and tkn.text in ("DEOPT_IF", "ERROR_IF", 
"EXIT_IF"):
             next(tkn_iter)
             in_if = 1
         elif tkn.kind == "LPAREN" and in_if:

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to