Author: Armin Rigo <[email protected]>
Branch:
Changeset: r48249:4519d98952d9
Date: 2011-10-19 23:57 +0200
http://bitbucket.org/pypy/pypy/changeset/4519d98952d9/
Log: Fix also the case of '__raw_input__'. Harder to test :-/
diff --git a/pypy/module/__builtin__/app_io.py
b/pypy/module/__builtin__/app_io.py
--- a/pypy/module/__builtin__/app_io.py
+++ b/pypy/module/__builtin__/app_io.py
@@ -27,6 +27,19 @@
co = compile(source.rstrip()+"\n", filename, 'exec')
exec co in glob, loc
+def _write_prompt(stdout, prompt):
+ print >> stdout, prompt,
+ try:
+ flush = stdout.flush
+ except AttributeError:
+ pass
+ else:
+ flush()
+ try:
+ stdout.softspace = 0
+ except (AttributeError, TypeError):
+ pass
+
def raw_input(prompt=''):
"""raw_input([prompt]) -> string
@@ -47,21 +60,10 @@
if (hasattr(sys, '__raw_input__') and
isinstance(stdin, file) and stdin.fileno() == 0 and stdin.isatty() and
isinstance(stdout, file) and stdout.fileno() == 1):
- if prompt is None:
- prompt = ''
- return sys.__raw_input__(prompt)
+ _write_prompt(stdout, '')
+ return sys.__raw_input__(str(prompt))
- print >> stdout, prompt,
- try:
- flush = stdout.flush
- except AttributeError:
- pass
- else:
- flush()
- try:
- stdout.softspace = 0
- except (AttributeError, TypeError):
- pass
+ _write_prompt(stdout, prompt)
line = stdin.readline()
if not line: # inputting an empty line gives line == '\n'
raise EOFError
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit