Skip to content

Fix Unicode line separators in iter_splitlines - #475

Merged
mahmoud merged 3 commits into
mahmoud:masterfrom
Jerry-val:fix/unicode-line-separators
Sep 7, 2026
Merged

mahmoud merged 3 commits into
mahmoud:masterfrom
Jerry-val:fix/unicode-line-separators

Conversation

@Jerry-val

Copy link
Copy Markdown
Contributor

iter_splitlines() uses \x2028 and \x2029 in its line-ending pattern. A hex escape consumes only two digits, so these match a space followed by 28 or 29 instead of the Unicode line and paragraph separators. For example, list(iter_splitlines('February 28, 2026')) returns ['February', ', 2026'], and indent() inherits the same text corruption.

Use \u2028 and \u2029 for the intended characters. Add regressions for both Unicode separators, leading/trailing separators, ordinary text containing 28 and 29, and indentation with mixed line endings.

Validation: all four new cases failed on the original code; python -m pytest --doctest-modules boltons tests -q passes with 629 tests on Python 3.13.14. git diff --check passes.

Checked related open and closed line-ending, splitlines and indentation PRs before implementation; no matching fix was found.

Prepared with Codex assistance and independently reviewed.

@mahmoud
mahmoud merged commit 45a2511 into mahmoud:master Sep 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants