if self.stdin:
if input is not None:
- if isinstance(input, str):
- input = input.encode()
self.stdin.write(input)
self.stdin.close()
def _communicate(self, input):
- if self.stdin:
- if isinstance(input, str): # Unicode
- input = input.encode("utf-8") # XXX What else?
- input = bytes(input)
read_set = []
write_set = []
stdout = None # Return
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- (stdout, stderr) = p.communicate("banana")
+ (stdout, stderr) = p.communicate(b"banana")
self.assertEqual(stdout, b"banana")
self.assertEqual(remove_stderr_debug_decorations(stderr),
b"pineapple")
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- data = p.communicate("lime")[0]
+ data = p.communicate(b"lime")[0]
self.assertEqual(data, b"lime")
Library
-------
+- Issue #2683: Fix inconsistency in subprocess.Popen.communicate(): the
+ argument now must be a bytes object in any case.
+
- Issue #3145: help("modules whatever") failed when trying to load the source
code of every single module of the standard library, including invalid files
used in the test suite.