mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
gh-115376: fix segfault in _testinternalcapi.compiler_codegen on bad input (#115379)
This commit is contained in:
parent
94f1334e52
commit
3a9e67a9fd
3 changed files with 35 additions and 15 deletions
|
@ -8,7 +8,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
|||
|
||||
def codegen_test(self, snippet, expected_insts):
|
||||
import ast
|
||||
a = ast.parse(snippet, "my_file.py", "exec");
|
||||
a = ast.parse(snippet, "my_file.py", "exec")
|
||||
insts = self.generate_code(a)
|
||||
self.assertInstructionsMatch(insts, expected_insts)
|
||||
|
||||
|
@ -54,3 +54,8 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
|||
('RETURN_VALUE', None),
|
||||
]
|
||||
self.codegen_test(snippet, expected)
|
||||
|
||||
def test_syntax_error__return_not_in_function(self):
|
||||
snippet = "return 42"
|
||||
with self.assertRaisesRegex(SyntaxError, "'return' outside function"):
|
||||
self.codegen_test(snippet, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue