summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-24 04:05:35 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-24 04:05:35 (GMT)
commitfa0054aa732176a1f9b1c79cd20198f43cfed334 (patch)
tree3a354b90b0d2876ab8c0fd72866a14ce2b879251 /Lib/subprocess.py
parentc126e8aae30043792f6318a5c4318b8203e75b33 (diff)
downloadcpython-fa0054aa732176a1f9b1c79cd20198f43cfed334.zip
cpython-fa0054aa732176a1f9b1c79cd20198f43cfed334.tar.gz
cpython-fa0054aa732176a1f9b1c79cd20198f43cfed334.tar.bz2
Make test_subprocess work. Fix universal newlines in io.py.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index fe64cc0..d46aa55 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -286,6 +286,7 @@ Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})
import sys
mswindows = (sys.platform == "win32")
+import io
import os
import traceback
@@ -542,23 +543,23 @@ class Popen(object):
if bufsize == 0:
bufsize = 1 # Nearly unbuffered (XXX for now)
if p2cwrite is not None:
- self.stdin = os.fdopen(p2cwrite, 'wb', bufsize)
+ self.stdin = io.open(p2cwrite, 'wb', bufsize)
+ if self.universal_newlines:
+ self.stdin = io.TextIOWrapper(self.stdin)
if c2pread is not None:
+ self.stdout = io.open(c2pread, 'rb', bufsize)
if universal_newlines:
- self.stdout = os.fdopen(c2pread, 'rU', bufsize)
- else:
- self.stdout = os.fdopen(c2pread, 'rb', bufsize)
+ self.stdout = io.TextIOWrapper(self.stdout)
if errread is not None:
+ self.stderr = io.open(errread, 'rb', bufsize)
if universal_newlines:
- self.stderr = os.fdopen(errread, 'rU', bufsize)
- else:
- self.stderr = os.fdopen(errread, 'rb', bufsize)
+ self.stderr = io.TextIOWrapper(self.stderr)
def _translate_newlines(self, data):
data = data.replace("\r\n", "\n")
data = data.replace("\r", "\n")
- return data
+ return str(data)
def __del__(self, sys=sys):
@@ -833,9 +834,9 @@ class Popen(object):
# impossible to combine with select (unless forcing no
# buffering).
if self.universal_newlines:
- if stdout:
+ if stdout is not None:
stdout = self._translate_newlines(stdout)
- if stderr:
+ if stderr is not None:
stderr = self._translate_newlines(stderr)
self.wait()
@@ -1009,7 +1010,6 @@ class Popen(object):
if data:
os.waitpid(self.pid, 0)
child_exception = pickle.loads(data)
- print("exc:", child_exception)
raise child_exception
@@ -1108,9 +1108,9 @@ class Popen(object):
# impossible to combine with select (unless forcing no
# buffering).
if self.universal_newlines:
- if stdout:
+ if stdout is not None:
stdout = self._translate_newlines(stdout)
- if stderr:
+ if stderr is not None:
stderr = self._translate_newlines(stderr)
self.wait()