diff options
author | Irit Katriel <iritkatriel@yahoo.com> | 2020-05-18 19:14:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 19:14:12 +0100 |
commit | e6578a226d8a8a13d1062d154fad0fef28ee2416 (patch) | |
tree | 49fc3caf99ad4a057ebea2d2be2c6e4d9727ede6 /Lib/ast.py | |
parent | 63b8e0cba3d43e53a8dd8878ee1443c8427f462d (diff) | |
download | cpython-e6578a226d8a8a13d1062d154fad0fef28ee2416.tar.gz cpython-e6578a226d8a8a13d1062d154fad0fef28ee2416.zip |
bpo-40662: Fixed ast.get_source_segment for ast nodes that have incomplete location information (GH-20157)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/ast.py')
-rw-r--r-- | Lib/ast.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/ast.py b/Lib/ast.py index 61fbe030a78..0d3b19d9223 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -332,6 +332,8 @@ def get_source_segment(source, node, *, padded=False): be padded with spaces to match its original position. """ try: + if node.end_lineno is None or node.end_col_offset is None: + return None lineno = node.lineno - 1 end_lineno = node.end_lineno - 1 col_offset = node.col_offset |