X Tutup
Skip to content

Commit a764a74

Browse files
committed
Fix FakeStdin.readline() (broke in r217).
Also return a bytestring instead of unicode.
1 parent fbe0046 commit a764a74

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

bpython/cli.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,21 @@ def readline(self):
181181
only one I've done anything with. The others are just there in case
182182
someone does something weird to stop it from blowing up."""
183183

184+
curses.raw(True)
184185
buffer = ''
185-
while True:
186-
key = self.interface.get_key()
187-
sys.stdout.write(key)
186+
try:
187+
while True:
188+
key = self.interface.get_key()
189+
sys.stdout.write(key)
188190
# Include the \n in the buffer - raw_input() seems to deal with trailing
189191
# linebreaks and will break if it gets an empty string.
190-
buffer += key
191-
if key == '\n':
192-
break
192+
buffer += key
193+
if key == '\n':
194+
break
195+
finally:
196+
curses.raw(False)
193197

194-
return buffer
198+
return buffer.encode(getpreferredencoding())
195199

196200
def read(self, x):
197201
pass

0 commit comments

Comments
 (0)
X Tutup