Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parso/python/pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def _visit_part(self, part, spacing, leaf):
should_be_indentation = n.indentation

self._last_indentation_tos = n
if n == node:
if n == node or n.parent is None:
break
n = n.parent

Expand Down
21 changes: 21 additions & 0 deletions tests/test_oss_regression_219.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import parso
import pytest


@pytest.mark.parametrize('newline', ['\n', '\r\n', '\r'])
def test_comment_after_line_continuation(newline):
code = '\\' + newline + '#'
grammar = parso.load_grammar()
module = grammar.parse(code)

try:
issues = grammar._get_normalizer_issues(module)
except AttributeError as error:
raise AssertionError(
'A comment after a line continuation must not crash normalization'
) from error

assert [(issue.code, issue.start_pos) for issue in issues] == [
(292, (2, 1))
]
assert module.get_code() == code
Loading