Permalink
Browse files

use unicode_to_str with readline.add_history

mutliline PR #838 added a call to readline.add_history, but without
the unicode/str protection used elsewhere, allowing `In[1]: u'é'` to crash IPython.

This makes the call match others in core.interativeshell.
  • Loading branch information...
minrk committed Oct 18, 2011
1 parent a030f7e commit 240f07741dded467b69a2d51bc4a1d9e1eb5bb6d
Showing with 3 additions and 1 deletion.
  1. +3 −1 IPython/frontend/terminal/interactiveshell.py
@@ -235,7 +235,9 @@ def _replace_rlhist_multiline(self, source_raw, hlen_before_cell):
hlen = self.readline.get_current_history_length()
for i in range(hlen - hlen_before_cell):
self.readline.remove_history_item(hlen - i - 1)
- self.readline.add_history(source_raw.rstrip())
+ stdin_encoding = sys.stdin.encoding or "utf-8"
+ self.readline.add_history(py3compat.unicode_to_str(source_raw.rstrip(),
+ stdin_encoding))
def interact(self, display_banner=None):
"""Closely emulate the interactive Python console."""

0 comments on commit 240f077

Please sign in to comment.