Commits

Amaury Forgeot d'Arc  committed e123d5c

[PyPy issue1221] raw_input() should return a string instead of unicode.
Actually a typo in the readline() call...
Test and fix.

  • Participants
  • Parent commits 9982325

Comments (0)

Files changed (2)

File pyrepl/readline.py

 
     def __init__(self):
         self.f_in = os.dup(0)
-        self.f_ut = os.dup(1)
+        self.f_out = os.dup(1)
 
     def get_reader(self):
         if self.reader is None:
         except _error:
             return _old_raw_input(prompt)
         reader.ps1 = prompt
-        return reader.readline(reader, startup_hook=self.startup_hook)
+        return reader.readline(startup_hook=self.startup_hook)
 
     def multiline_input(self, more_lines, ps1, ps2, returns_unicode=False):
         """Read an input on possibly multiple lines, asking for more

File testing/test_readline.py

+from pyrepl.readline import _ReadlineWrapper
+import os, pty
+
+def test_raw_input():
+    readline_wrapper = _ReadlineWrapper()
+    master, slave = pty.openpty()
+    readline_wrapper.f_in = slave
+    os.write(master, 'input\n')
+    result = readline_wrapper.raw_input('prompt:')
+    assert result == 'input'
+    # A bytes string on python2, a unicode string on python3.
+    assert isinstance(result, str)
+