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: 2 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ Batuhan Taskaya (@isidentical) <isidentical@gmail.com>
Jocelyn Boullier (@Kazy) <jocelyn@boullier.bzh>


eunwoo song (@be-student)

Note: (@user) means a github user name.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changelog
Unreleased
++++++++++

- Fix a PEP8 normalizer crash on comments following a line continuation.

0.8.7 (2026-05-02)
++++++++++++++++++

Expand Down
4 changes: 3 additions & 1 deletion parso/python/pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ def _visit_part(self, part, spacing, leaf):
should_be_indentation = n.indentation

self._last_indentation_tos = n
if n == node:
# A continuation in this prefix can make node newer
# than the saved stack. Always stop at its root.
if n == node or n.parent is None:
break
n = n.parent

Expand Down
11 changes: 11 additions & 0 deletions test/test_pep8.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

import parso


Expand Down Expand Up @@ -40,3 +42,12 @@ def test_shebang():
assert not issues('#!\n')
assert not issues('#!/foo\n')
assert not issues('#! python\n')


@pytest.mark.parametrize('newline', ['\n', '\r\n', '\r'])
@pytest.mark.parametrize('prefix', ['', 'x = 1\n', 'if True:\n pass\n'])
@pytest.mark.parametrize('comment', ['#', '# comment', '# comment\n'])
def test_comment_after_line_continuation(newline, prefix, comment):
code = prefix + '\\' + newline + comment
found = issues(code)
assert (292 in [issue.code for issue in found]) == (not code.endswith('\n'))
Loading