Skip to content

Commit b772e1b

Browse files
committed
Fix urwid tests under Python 3
1 parent f9c8c8e commit b772e1b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bpython/test/test_crashers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import textwrap
1010

1111
from bpython.test import unittest, TEST_CONFIG
12+
from bpython.config import getpreferredencoding
1213

1314
try:
1415
from twisted.internet import reactor
@@ -57,6 +58,7 @@ def run_bpython(self, input):
5758
Returns bpython's output.
5859
"""
5960
result = Deferred()
61+
encoding = getpreferredencoding()
6062

6163
class Protocol(ProcessProtocol):
6264
STATES = (SEND_INPUT, COLLECT) = range(2)
@@ -68,7 +70,7 @@ def __init__(self):
6870
self.state = next(self.states)
6971

7072
def outReceived(self, data):
71-
self.data += data
73+
self.data += data.decode(encoding)
7274
if self.delayed_call is not None:
7375
self.delayed_call.cancel()
7476
self.delayed_call = reactor.callLater(0.5, self.next)
@@ -79,7 +81,7 @@ def next(self):
7981
index = self.data.find(">>> ")
8082
if index >= 0:
8183
self.data = self.data[index + 4 :]
82-
self.transport.write(input)
84+
self.transport.write(input.encode(encoding))
8385
self.state = next(self.states)
8486
else:
8587
self.transport.closeStdin()

0 commit comments

Comments
 (0)