Skip to content

Fix newline handling in stdout and stderr #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2017
Merged

Conversation

ata2001
Copy link
Contributor

@ata2001 ata2001 commented May 27, 2017

Fixes #658.

def send_to_stdout(self, output):
"""Send unicode string to Repl stdout"""
if not output: return
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add break the line after :.

@@ -1157,9 +1165,16 @@ def send_to_stderr(self, error):

Must be able to handle FmtStrs because interpreter pass in
tracebacks already formatted."""
if not error: return
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add break the line after :.

lines = output.split('\n')
if output == len(output) * '\n':
# If the string consist only of newline characters,
# str.split returns one more empty strings.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since at this point split was already called, I'd feel that if all(len(line) == 0 for line in lines): would be nicer.

Copy link
Contributor Author

@ata2001 ata2001 May 28, 2017

Choose a reason for hiding this comment

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

What about if all(not line for line in lines):?

if error == len(error) * '\n':
# If the string consist only of newline characters,
# str.split returns one more empty strings.
lines = lines[:-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the other splitcomment.

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