FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: split process output on \n instead of os.EOL by Bolt4243 · Pull Request #332 · extrabacon/python-shell · GitHub

Repository navigation

fix: split process output on \n instead of os.EOL - #332

Open
Bolt4243 wants to merge 1 commit into
extrabacon:masterfrom
Bolt4243:fix/newline-split
Open

Bolt4243 wants to merge 1 commit into
extrabacon:masterfrom
Bolt4243:fix/newline-split

Conversation

Copy link
Copy Markdown

Fixes #331.

NewlineTransformer split stdout/stderr on os.EOL. On Windows that is \r\n, so output using bare \n line endings was never split into messages: the data was buffered in _lastLineData and dropped, because _flush runs after the stream's end handler has already resolved the run()/end() callback. print() worked only because Python's text-mode stdout translates \n to \r\n on Windows.

Split on /\r?\n/ so both line endings are handled.

Added a regression test against the exported NewlineTransformer (deterministic and OS independent). It fails on the previous code for the bare-\n case and passes with the fix.

NewlineTransformer split stdout/stderr on os.EOL. On Windows that is
\r\n, so output using bare \n line endings was never split into
messages: the data was buffered and dropped, because _flush runs after
the stream's end handler has already resolved the run()/end() callback.
Normal print() worked only because Python's text-mode stdout translates
\n to \r\n on Windows.

Split on /\r?\n/ so both line endings are handled.

PNHD left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Reviewed current head 9fe76e4 against #331.

Splitting on /\r?\n/ fixes bare-LF output on Windows while preserving CRLF handling. Because _lastLineData is prepended before splitting, a CRLF pair split across two stream chunks is still reconstructed and emitted as one normal line.

The focused transformer tests cover both LF and CRLF without expanding into the separate bare-CR behavior from #325. LGTM.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output using bare \n line endings is dropped on Windows

2 participants


Back | FazBrowse Home | New Git URL