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

Remove redundant blank lines to match CPython REPL #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ptpython/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ def compile_with_flags(code, mode):
out_prompt = self.get_output_prompt()

try:
result_str = '%r\n' % (result, )
result_str = '%r' % (result, )
except UnicodeDecodeError:
# In Python 2: `__repr__` should return a bytestring,
# so to put it in a unicode context could raise an
# exception that the 'ascii' codec can't decode certain
# characters. Decode as utf-8 in that case.
result_str = '%s\n' % repr(result).decode('utf-8')
result_str = '%s' % repr(result).decode('utf-8')

# Align every line to the first one.
line_sep = '\n' + ' ' * fragment_list_width(out_prompt)
result_str = line_sep.join(result_str.splitlines()) + '\n'
result_str = line_sep.join(result_str.splitlines())

# Write output tokens.
if self.enable_syntax_highlighting:
Expand All @@ -155,7 +155,7 @@ def compile_with_flags(code, mode):
print_formatted_text(
formatted_output, style=self._current_style,
style_transformation=self.style_transformation,
include_default_pygments_style=False)
include_default_pygments_style=False, end='')

# If not a valid `eval` expression, run using `exec` instead.
except SyntaxError:
Expand Down Expand Up @@ -212,7 +212,7 @@ def _handle_exception(self, e):
def _handle_keyboard_interrupt(self, e):
output = self.app.output

output.write('\rKeyboardInterrupt\n\n')
output.write('\rKeyboardInterrupt\n')
output.flush()


Expand Down