Skip to content

Commit c648c8c

Browse files
author
Marien Zwart
committed
Fix typing non-ascii into bpython-urwid (in recent urwids).
Bug reported by mercutio22 on freenode.
1 parent 6e75552 commit c648c8c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

bpython/urwid.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,20 @@ def prompt(self, more):
812812
# XXX is this the right place?
813813
self.rl_history.reset()
814814
# XXX what is s_hist?
815+
816+
# We need the caption to use unicode as urwid normalizes later
817+
# input to be the same type, using ascii as encoding. If the
818+
# caption is bytes this breaks typing non-ascii into bpython.
819+
# Currently this decodes using ascii as I do not know where
820+
# ps1 is getting loaded from. If anyone wants to make
821+
# non-ascii prompts work feel free to fix this.
815822
if not more:
816-
self.edit = BPythonEdit(self.config,
817-
caption=('prompt', self.ps1))
823+
caption = ('prompt', self.ps1.decode('ascii'))
818824
self.stdout_hist += self.ps1
819825
else:
820-
self.edit = BPythonEdit(self.config,
821-
caption=('prompt_more', self.ps2))
826+
caption = ('prompt_more', self.ps2.decode('ascii'))
822827
self.stdout_hist += self.ps2
828+
self.edit = BPythonEdit(self.config, caption=caption)
823829

824830
urwid.connect_signal(self.edit, 'change', self.on_input_change)
825831
urwid.connect_signal(self.edit, 'edit-pos-changed',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy