Skip to content

gh-144018: Preserve tab indentation across explicit line continuations - #159017

Open
emerardd wants to merge 1 commit into
python:mainfrom
emerardd:fix/gh-144018-continuation-tab-indent
Open

emerardd wants to merge 1 commit into
python:mainfrom
emerardd:fix/gh-144018-continuation-tab-indent

Conversation

@emerardd

@emerardd emerardd commented Oct 8, 2026 •

Copy link
Copy Markdown

Explicit line continuation currently restores both indentation columns from the expanded column. This causes consistently tab-indented blocks to raise TabError and can also allow ambiguous tab/space indentation that would otherwise be rejected.

Preserve the alternate indentation column separately when recording the first continuation, and restore each column from its own saved value. Keep the existing zero-indentation handling unchanged.

Add regression coverage for tabs, consistent mixed prefixes and spaces, repeated continuations, LF/CRLF, first and subsequent continued statements, and rejection of ambiguous tab/space indentation. The new tests fail with the unpatched lexer and pass with the fix.

Validation: Windows x64 CPython 3.16 debug build; test_syntax, test_tokenize, test_grammar and test_ast pass (575 tests, 2 skipped). Ruff and git diff --check pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant