Skip to content

Commit

Permalink
Fix potential issue with line number recognition on non Str/Expr nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
phihos committed Nov 8, 2018
1 parent e893b8b commit 782fc9a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion astmonkey/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _get_current_line_no(self):

@classmethod
def _get_actual_lineno(cls, node):
if node.col_offset == -1 and isinstance(node, (ast.Expr, ast.Str)):
if isinstance(node, (ast.Expr, ast.Str)) and node.col_offset == -1:
str_content = cls._get_string_content(node)
node_lineno = node.lineno - str_content.count('\n')
else:
Expand Down

0 comments on commit 782fc9a

Please sign in to comment.