diff options
author | Batuhan Taskaya <batuhanosmantaskaya@gmail.com> | 2020-08-05 13:32:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-05 13:32:32 (GMT) |
commit | 8f4380d2f5839a321475104765221a7394a9d649 (patch) | |
tree | c853088e18755a66c012181c324248da8db29796 /Lib/test/test_ast.py | |
parent | 270b4ad4df795783d417ba15080da8f95e598689 (diff) | |
download | cpython-8f4380d2f5839a321475104765221a7394a9d649.zip cpython-8f4380d2f5839a321475104765221a7394a9d649.tar.gz cpython-8f4380d2f5839a321475104765221a7394a9d649.tar.bz2 |
bpo-40726: handle uninitalized end_lineno on ast.increment_lineno (GH-20312)
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r-- | Lib/test/test_ast.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 78e4a56..f5aef61 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -812,6 +812,12 @@ Module( 'lineno=1, col_offset=4, end_lineno=1, end_col_offset=5), lineno=1, ' 'col_offset=0, end_lineno=1, end_col_offset=5))' ) + src = ast.Call(col_offset=1, lineno=1, end_lineno=1, end_col_offset=1) + new = ast.copy_location(src, ast.Call(col_offset=None, lineno=None)) + self.assertIsNone(new.end_lineno) + self.assertIsNone(new.end_col_offset) + self.assertEqual(new.lineno, 1) + self.assertEqual(new.col_offset, 1) def test_fix_missing_locations(self): src = ast.parse('write("spam")') @@ -851,6 +857,11 @@ Module( 'lineno=4, col_offset=4, end_lineno=4, end_col_offset=5), lineno=4, ' 'col_offset=0, end_lineno=4, end_col_offset=5))' ) + src = ast.Call( + func=ast.Name("test", ast.Load()), args=[], keywords=[], lineno=1 + ) + self.assertEqual(ast.increment_lineno(src).lineno, 2) + self.assertIsNone(ast.increment_lineno(src).end_lineno) def test_iter_fields(self): node = ast.parse('foo()', mode='eval') |