Repository navigation
Fix Unicode line separators in iter_splitlines - #475
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
iter_splitlines()uses\x2028and\x2029in its line-ending pattern. A hex escape consumes only two digits, so these match a space followed by28or29instead of the Unicode line and paragraph separators. For example,list(iter_splitlines('February 28, 2026'))returns['February', ', 2026'], andindent()inherits the same text corruption.Use
\u2028and\u2029for the intended characters. Add regressions for both Unicode separators, leading/trailing separators, ordinary text containing28and29, and indentation with mixed line endings.Validation: all four new cases failed on the original code;
python -m pytest --doctest-modules boltons tests -qpasses with 629 tests on Python 3.13.14.git diff --checkpasses.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.