mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-92597: Ensure that AST nodes without explicit end positions can be compiled (GH-93359)
(cherry picked from commit 705eaec28f
)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
29bfabe970
commit
b425d887aa
4 changed files with 35 additions and 13 deletions
|
@ -362,6 +362,14 @@ class AST_Tests(unittest.TestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
compile(tree, '<string>', 'exec')
|
||||
|
||||
def test_compilation_of_ast_nodes_with_default_end_position_values(self):
|
||||
tree = ast.Module(body=[
|
||||
ast.Import(names=[ast.alias(name='builtins', lineno=1, col_offset=0)], lineno=1, col_offset=0),
|
||||
ast.Import(names=[ast.alias(name='traceback', lineno=0, col_offset=0)], lineno=0, col_offset=1)
|
||||
], type_ignores=[])
|
||||
|
||||
# Check that compilation doesn't crash. Note: this may crash explicitly only on debug mode.
|
||||
compile(tree, "<string>", "exec")
|
||||
|
||||
def test_slice(self):
|
||||
slc = ast.parse("x[::]").body[0].value.slice
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue