changeset: 101322:f5e69e2f50d7 parent: 101319:62d844d2bd07 parent: 101321:148757a88f19 user: Yury Selivanov date: Fri May 13 15:39:09 2016 -0400 files: Misc/NEWS description: Merge 3.5 (issue #26848) diff -r 62d844d2bd07 -r f5e69e2f50d7 Lib/asyncio/subprocess.py --- a/Lib/asyncio/subprocess.py Fri May 13 21:19:22 2016 +0300 +++ b/Lib/asyncio/subprocess.py Fri May 13 15:39:09 2016 -0400 @@ -166,7 +166,7 @@ @coroutine def communicate(self, input=None): - if input: + if input is not None: stdin = self._feed_stdin(input) else: stdin = self._noop() diff -r 62d844d2bd07 -r f5e69e2f50d7 Lib/test/test_asyncio/test_subprocess.py --- a/Lib/test/test_asyncio/test_subprocess.py Fri May 13 21:19:22 2016 +0300 +++ b/Lib/test/test_asyncio/test_subprocess.py Fri May 13 15:39:09 2016 -0400 @@ -287,6 +287,25 @@ self.assertEqual(output.rstrip(), b'3') self.assertEqual(exitcode, 0) + def test_empty_input(self): + @asyncio.coroutine + def empty_input(): + code = 'import sys; data = sys.stdin.read(); print(len(data))' + proc = yield from asyncio.create_subprocess_exec( + sys.executable, '-c', code, + stdin=asyncio.subprocess.PIPE, + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE, + close_fds=False, + loop=self.loop) + stdout, stderr = yield from proc.communicate(b'') + exitcode = yield from proc.wait() + return (stdout, exitcode) + + output, exitcode = self.loop.run_until_complete(empty_input()) + self.assertEqual(output.rstrip(), b'0') + self.assertEqual(exitcode, 0) + def test_cancel_process_wait(self): # Issue #23140: cancel Process.wait() diff -r 62d844d2bd07 -r f5e69e2f50d7 Misc/NEWS --- a/Misc/NEWS Fri May 13 21:19:22 2016 +0300 +++ b/Misc/NEWS Fri May 13 15:39:09 2016 -0400 @@ -952,6 +952,9 @@ - Issue #26406: Avoid unnecessary serialization of getaddrinfo(3) calls on current versions of OpenBSD and NetBSD. Patch by A. Jesse Jiryu Davis. +- Issue #26848: Fix asyncio/subprocess.communicate() to handle empty input. + Patch by Jack O'Connor. + IDLE ----