Skip to content

Commit 5786d10

Browse files
author
Bob Farrell
committed
Unprintable character handling fix
Things like C-p and C-n and all that were just being echoed as ^P, and only one character was being put into the buffer, whereas two were being echoed. Now only printable characters are accepted for regular input. committer: Bob Farrell <bob@keys.(none)>
1 parent 782a2d1 commit 5786d10

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎bpython.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import struct
4242
import termios
4343
import fcntl
44+
import string
4445
import ConfigParser
4546
from bpython.formatter import BPythonFormatter
4647

@@ -810,7 +811,7 @@ def echo( self, s, redraw=True ):
810811
s = s.replace( '\x03', '' )
811812
s = s.replace( '\x01', '' )
812813

813-
814+
814815
self.scr.addstr( s, a )
815816

816817
if redraw and not self.evaluating:
@@ -953,7 +954,7 @@ def p_key( self ):
953954
elif self.c == '\t':
954955
return self.tab()
955956

956-
elif len( self.c ) == 1 and ord( self.c ) <= 127:
957+
elif len( self.c ) == 1 and self.c in string.printable:#ord( self.c ) <= 127:
957958
self.addc( self.c )
958959
self.print_line( self.s )
959960

0 commit comments

Comments
 (0)