Skip to content

Commit 3669aa8

Browse files
committed
fix test_raw_input
1 parent 53e806d commit 3669aa8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pyrepl/readline.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,13 @@ def raw_input(self, prompt=''):
205205
except _error:
206206
return _old_raw_input(prompt)
207207
reader.ps1 = prompt
208+
209+
ret = reader.readline(startup_hook=self.startup_hook)
210+
if sys.version_info < (3, ):
211+
return ret
208212
# Unicode/str is required for Python 3 (3.5.2).
209-
return unicode(reader.readline(startup_hook=self.startup_hook),
210-
ENCODING)
213+
# Ref: https://bitbucket.org/pypy/pyrepl/issues/20/#comment-30647029
214+
return unicode(ret, ENCODING)
211215

212216
def multiline_input(self, more_lines, ps1, ps2, returns_unicode=False):
213217
"""Read an input on possibly multiple lines, asking for more

testing/test_readline.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
if sys.version_info < (3, ):
77
bytes_type = str
8-
unicode_type = unicode
8+
unicode_type = unicode # noqa: F821
99
else:
1010
bytes_type = bytes
1111
unicode_type = str
@@ -37,5 +37,9 @@ def test_raw_input():
3737
os.write(master, b'input\n')
3838

3939
result = readline_wrapper.raw_input('prompt:')
40-
assert result == b'input'
41-
assert isinstance(result, bytes_type)
40+
if sys.version_info < (3, ):
41+
assert result == b'input'
42+
assert isinstance(result, bytes_type)
43+
else:
44+
assert result == 'input'
45+
assert isinstance(result, unicode_type)

0 commit comments

Comments
 (0)