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
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ Tim Gates (@timgates42) <tim.gates@iress.com>
Batuhan Taskaya (@isidentical) <isidentical@gmail.com>
Jocelyn Boullier (@Kazy) <jocelyn@boullier.bzh>

Rupayon Haldar (@rupayon123)

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

- Avoid a normalizer crash for a standalone line continuation followed by a
comment, and keep indentation checks on the active continuation stack.

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

Expand Down
5 changes: 3 additions & 2 deletions parso/python/pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def _visit_part(self, part, spacing, leaf):
indentation = spacing.value
if node.type == IndentationTypes.BACKSLASH \
and self._previous_part.type == 'newline':
self._indentation_tos = self._indentation_tos.parent
self._indentation_tos = node = node.parent

if not self._check_tabs_spaces(spacing):
should_be_indentation = node.indentation
Expand All @@ -444,7 +444,8 @@ def _visit_part(self, part, spacing, leaf):
should_be_indentation = n.indentation

self._last_indentation_tos = n
if n == node:
# Prefix continuations may not be in the previous stack.
if n == node or n.parent is None:
break
n = n.parent

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


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


@pytest.mark.parametrize("ending, expected_codes", [("", [292]), ("\n", [])])
def test_comment_after_standalone_backslash(each_version, ending, expected_codes):
grammar = parso.load_grammar(version=each_version)
module = grammar.parse("\\\n#" + ending)
found = grammar._get_normalizer_issues(module)
assert [issue.code for issue in found] == expected_codes
Loading