[pypy-commit] pyrepl default: dup fds for UnixConsole and ad check for closed stdout to flishing, fixes #1
RonnyPfannschmidt
noreply at buildbot.pypy.org
Thu May 3 14:32:01 CEST 2012
Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch:
Changeset: r186:1793b23a5a1b
Date: 2012-05-03 14:31 +0200
http://bitbucket.org/pypy/pyrepl/changeset/1793b23a5a1b/
Log: dup fds for UnixConsole and ad check for closed stdout to flishing,
fixes #1
diff --git a/pyrepl/python_reader.py b/pyrepl/python_reader.py
--- a/pyrepl/python_reader.py
+++ b/pyrepl/python_reader.py
@@ -192,7 +192,8 @@
self.showsyntaxerror("<input>")
else:
self.runcode(code)
- sys.stdout.flush()
+ if sys.stdout and not sys.stdout.closed:
+ sys.stdout.flush()
def interact(self):
while 1:
@@ -382,7 +383,7 @@
encoding = None
else:
encoding = None # so you get ASCII...
- con = UnixConsole(0, 1, None, encoding)
+ con = UnixConsole(os.dup(0), os.dup(1), None, encoding)
if print_banner:
print("Python", sys.version, "on", sys.platform)
print('Type "help", "copyright", "credits" or "license" '\
diff --git a/pyrepl/readline.py b/pyrepl/readline.py
--- a/pyrepl/readline.py
+++ b/pyrepl/readline.py
@@ -174,13 +174,15 @@
# ____________________________________________________________
class _ReadlineWrapper(object):
- f_in = 0
- f_out = 1
reader = None
saved_history_length = -1
startup_hook = None
config = ReadlineConfig()
+ def __init__(self):
+ self.f_in = os.dup(0)
+ self.f_ut = os.dup(1)
+
def get_reader(self):
if self.reader is None:
console = UnixConsole(self.f_in, self.f_out, encoding=ENCODING)
More information about the pypy-commit
mailing list