| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -330,7 +330,7 @@ def __init__(self, scr, interp, statusbar, config, idle=None): | |||
| 330 | 330 | repl.Repl.__init__(self, interp, config) | |
| 331 | 331 | self.interp.writetb = self.writetb | |
| 332 | 332 | self.scr = scr | |
| 333 | - self.stdout_hist = '' | ||
| 333 | + self.stdout_hist = '' # native str (bytes in Py2, unicode in Py3) | ||
| 334 | 334 | self.list_win = newwin(get_colpair(config, 'background'), 1, 1, 1, 1) | |
| 335 | 335 | self.cpos = 0 | |
| 336 | 336 | self.do_exit = False | |
@@ -1066,13 +1066,19 @@ def prompt(self, more): | |||
| 1066 | 1066 | """Show the appropriate Python prompt""" | |
| 1067 | 1067 | if not more: | |
| 1068 | 1068 | self.echo("\x01%s\x03%s" % (self.config.color_scheme['prompt'], self.ps1)) | |
| 1069 | - self.stdout_hist += self.ps1 | ||
| 1069 | + if py3: | ||
| 1070 | + self.stdout_hist += self.ps1 | ||
| 1071 | + else: | ||
| 1072 | + self.stdout_hist += self.ps1.encode(getpreferredencoding()) | ||
| 1070 | 1073 | self.s_hist.append('\x01%s\x03%s\x04' % | |
| 1071 | 1074 | (self.config.color_scheme['prompt'], self.ps1)) | |
| 1072 | 1075 | else: | |
| 1073 | 1076 | prompt_more_color = self.config.color_scheme['prompt_more'] | |
| 1074 | 1077 | self.echo("\x01%s\x03%s" % (prompt_more_color, self.ps2)) | |
| 1075 | - self.stdout_hist += self.ps2 | ||
| 1078 | + if py3: | ||
| 1079 | + self.stdout_hist += self.ps2 | ||
| 1080 | + else: | ||
| 1081 | + self.stdout_hist += self.ps2.encode(getpreferredencoding()) | ||
| 1076 | 1082 | self.s_hist.append('\x01%s\x03%s\x04' % (prompt_more_color, self.ps2)) | |
| 1077 | 1083 | ||
| 1078 | 1084 | def push(self, s, insert_into_history=True): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -596,7 +596,7 @@ def __init__(self, event_loop, palette, interpreter, config): | |||
| 596 | 596 | self.tooltip = urwid.ListBox(urwid.SimpleListWalker([])) | |
| 597 | 597 | self.tooltip.grid = None | |
| 598 | 598 | self.overlay = Tooltip(self.listbox, self.tooltip) | |
| 599 | - self.stdout_hist = '' | ||
| 599 | + self.stdout_hist = '' # native str (bytes in Py2, unicode in Py3) | ||
| 600 | 600 | ||
| 601 | 601 | self.frame = urwid.Frame(self.overlay) | |
| 602 | 602 | ||
@@ -976,17 +976,17 @@ def prompt(self, more): | |||
| 976 | 976 | # input to be the same type, using ascii as encoding. If the | |
| 977 | 977 | # caption is bytes this breaks typing non-ascii into bpython. | |
| 978 | 978 | if not more: | |
| 979 | + caption = ('prompt', self.ps1) | ||
| 979 | 980 | if py3: | |
| 980 | - caption = ('prompt', self.ps1) | ||
| 981 | + self.stdout_hist += self.ps1 | ||
| 981 | 982 | else: | |
| 982 | - caption = ('prompt', self.ps1.decode(getpreferredencoding())) | ||
| 983 | - self.stdout_hist += self.ps1 | ||
| 983 | + self.stdout_hist += self.ps1.encode(getpreferredencoding()) | ||
| 984 | 984 | else: | |
| 985 | + caption = ('prompt_more', self.ps2) | ||
| 985 | 986 | if py3: | |
| 986 | - caption = ('prompt_more', self.ps2) | ||
| 987 | + self.stdout_hist += self.ps2 | ||
| 987 | 988 | else: | |
| 988 | - caption = ('prompt_more', self.ps2.decode(getpreferredencoding())) | ||
| 989 | - self.stdout_hist += self.ps2 | ||
| 989 | + self.stdout_hist += self.ps2.encode(getpreferredencoding()) | ||
| 990 | 990 | self.edit = BPythonEdit(self.config, caption=caption) | |
| 991 | 991 | ||
| 992 | 992 | urwid.connect_signal(self.edit, 'change', self.on_input_change) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments