mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
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>
This commit is contained in:
parent
63b8e0cba3
commit
e6578a226d
3 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue