1215 # call write() so output goes through subclassed implementation |
1215 # call write() so output goes through subclassed implementation |
1216 # e.g. color extension on Windows |
1216 # e.g. color extension on Windows |
1217 self.write(prompt, prompt=True) |
1217 self.write(prompt, prompt=True) |
1218 self.flush() |
1218 self.flush() |
1219 |
1219 |
1220 # instead of trying to emulate raw_input, swap (self.fin, |
|
1221 # self.fout) with (sys.stdin, sys.stdout) |
|
1222 oldin = sys.stdin |
|
1223 oldout = sys.stdout |
|
1224 sys.stdin = self.fin |
|
1225 sys.stdout = self.fout |
|
1226 # prompt ' ' must exist; otherwise readline may delete entire line |
1220 # prompt ' ' must exist; otherwise readline may delete entire line |
1227 # - http://bugs.python.org/issue12833 |
1221 # - http://bugs.python.org/issue12833 |
1228 with self.timeblockedsection('stdio'): |
1222 with self.timeblockedsection('stdio'): |
1229 line = raw_input(' ') |
1223 line = util.bytesinput(self.fin, self.fout, r' ') |
1230 sys.stdin = oldin |
|
1231 sys.stdout = oldout |
|
1232 |
1224 |
1233 # When stdin is in binary mode on Windows, it can cause |
1225 # When stdin is in binary mode on Windows, it can cause |
1234 # raw_input() to emit an extra trailing carriage return |
1226 # raw_input() to emit an extra trailing carriage return |
1235 if pycompat.oslinesep == '\r\n' and line and line[-1] == '\r': |
1227 if pycompat.oslinesep == '\r\n' and line and line[-1] == '\r': |
1236 line = line[:-1] |
1228 line = line[:-1] |