You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
preserve_blank_lines=True counts each CRLF as two line breaks #103
With preserve_blank_lines=True, a Windows line ending (\r\n) is counted as two line endings, so every CRLF in the input adds an extra blank line to the output.
\r\n is two characters but one line ending, so split produces an empty element between the two, and joining the pieces with "\n" turns it into a blank line. The default branch (preserve_blank_lines=False) uses [\r\n]+ and is not affected.
This reaches any caller that passes CRLF text to the library API: HTTP response bodies, subprocess output, files read with newline='', output from Windows tools. The CLI is not affected, because it opens files in text mode and universal newlines convert CRLF to LF before titlecase sees the text.
A fix would be to treat one line ending as one separator, for example:
lines=regex.split(r'\r\n|\r|\n', text)
TestBlankLines.test_complex_blanks only uses \n, so this path currently has no coverage.
The same behaviour is present in the 2.4.1 release, so it is not specific to main.
Activity