Skip to content
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

Fix bug in fix_print.py fixer #596

Merged

Conversation

abjonnes
Copy link

@abjonnes abjonnes commented Nov 11, 2021

When the print ends with a non-space whitespace character, an extra
space character should not be printed at the end.

From the python2 documentation:

A space is written before each object is (converted and) written, unless the output system believes it is positioned at the beginning of a line. This is the case (1) when no characters have yet been written to standard output, (2) when the last character written to standard output is a whitespace character except ' ', or (3) when the last write operation on standard output was not a print statement.

The changes here don't do this perfectly (e.g. when a printed string variable ends with a tab), but capture the common case of when a literal string which ends in a tab or line feed is printed with a trailing comma, like print "something\t",.

Addresses (at least partially) #473.

When the print ends with a non-space whitespace character, an extra
space character should not be printed at the end.
@edschofield edschofield merged commit 17e4bbd into PythonCharmers:master Nov 11, 2021
@edschofield
Copy link
Contributor

Many thanks, @abjonnes !

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.

None yet

2 participants