diff options
author | Guido van Rossum <guido@python.org> | 2007-05-15 23:18:55 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-15 23:18:55 (GMT) |
commit | c9e363c2eb3eed920bcd0d08a2eabdfa939b1270 (patch) | |
tree | dcccf25bf9c8e8dcd31dca35bb77d4d95f4e5d56 /Lib/subprocess.py | |
parent | af2362a584c01dec32d7f1a23d3e6f653f11dde4 (diff) | |
download | cpython-c9e363c2eb3eed920bcd0d08a2eabdfa939b1270.zip cpython-c9e363c2eb3eed920bcd0d08a2eabdfa939b1270.tar.gz cpython-c9e363c2eb3eed920bcd0d08a2eabdfa939b1270.tar.bz2 |
Make test_subprocess pass. The subprocess module now reads and writes
bytes instead of strings. We'll see how long that lasts.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 22de0ce..2d02df6 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -830,7 +830,7 @@ class Popen(object): # object do the translation: It is based on stdio, which is # impossible to combine with select (unless forcing no # buffering). - if self.universal_newlines and hasattr(file, 'newlines'): + if self.universal_newlines: if stdout: stdout = self._translate_newlines(stdout) if stderr: @@ -1044,6 +1044,8 @@ class Popen(object): def _communicate(self, input): + if isinstance(input, str): # Unicode + input = input.encode("utf-8") # XXX What else? read_set = [] write_set = [] stdout = None # Return @@ -1080,29 +1082,29 @@ class Popen(object): if self.stdout in rlist: data = os.read(self.stdout.fileno(), 1024) - if data == "": + if not data: self.stdout.close() read_set.remove(self.stdout) stdout.append(data) if self.stderr in rlist: data = os.read(self.stderr.fileno(), 1024) - if data == "": + if not data: self.stderr.close() read_set.remove(self.stderr) stderr.append(data) # All data exchanged. Translate lists into strings. if stdout is not None: - stdout = ''.join(stdout) + stdout = b''.join(stdout) if stderr is not None: - stderr = ''.join(stderr) + stderr = b''.join(stderr) # Translate newlines, if requested. We cannot let the file # object do the translation: It is based on stdio, which is # impossible to combine with select (unless forcing no # buffering). - if self.universal_newlines and hasattr(file, 'newlines'): + if self.universal_newlines: if stdout: stdout = self._translate_newlines(stdout) if stderr: |