@@ -596,7 +596,7 @@ def __init__(self, event_loop, palette, interpreter, config):
596596 self .tooltip = urwid .ListBox (urwid .SimpleListWalker ([]))
597597 self .tooltip .grid = None
598598 self .overlay = Tooltip (self .listbox , self .tooltip )
599- self .stdout_hist = ''
599+ self .stdout_hist = '' # native str (bytes in Py2, unicode in Py3)
600600
601601 self .frame = urwid .Frame (self .overlay )
602602
@@ -976,17 +976,17 @@ def prompt(self, more):
976976 # input to be the same type, using ascii as encoding. If the
977977 # caption is bytes this breaks typing non-ascii into bpython.
978978 if not more :
979+ caption = ('prompt' , self .ps1 )
979980 if py3 :
980- caption = ( 'prompt' , self .ps1 )
981+ self . stdout_hist += self .ps1
981982 else :
982- caption = ('prompt' , self .ps1 .decode (getpreferredencoding ()))
983- self .stdout_hist += self .ps1
983+ self .stdout_hist += self .ps1 .encode (getpreferredencoding ())
984984 else :
985+ caption = ('prompt_more' , self .ps2 )
985986 if py3 :
986- caption = ( 'prompt_more' , self .ps2 )
987+ self . stdout_hist += self .ps2
987988 else :
988- caption = ('prompt_more' , self .ps2 .decode (getpreferredencoding ()))
989- self .stdout_hist += self .ps2
989+ self .stdout_hist += self .ps2 .encode (getpreferredencoding ())
990990 self .edit = BPythonEdit (self .config , caption = caption )
991991
992992 urwid .connect_signal (self .edit , 'change' , self .on_input_change )
0 commit comments