summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2016-05-13 19:39:09 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2016-05-13 19:39:09 (GMT)
commit059320bab880ec97327967f124f2430436e5d66d (patch)
tree51e248492aa8f97c2cc6d4fbdc142cb097814efa /Lib
parent91762da45bab10df71b01bab2587fcbaed58b53c (diff)
parent7657f6ba218aa59ee085f2001dc44247f2fd0d4c (diff)
downloadcpython-059320bab880ec97327967f124f2430436e5d66d.zip
cpython-059320bab880ec97327967f124f2430436e5d66d.tar.gz
cpython-059320bab880ec97327967f124f2430436e5d66d.tar.bz2
Merge 3.5 (issue #26848)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/subprocess.py2
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py19
2 files changed, 20 insertions, 1 deletions
diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py
index ead4039..b2f5304 100644
--- a/Lib/asyncio/subprocess.py
+++ b/Lib/asyncio/subprocess.py
@@ -166,7 +166,7 @@ class Process:
@coroutine
def communicate(self, input=None):
- if input:
+ if input is not None:
stdin = self._feed_stdin(input)
else:
stdin = self._noop()
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index e90f17d..4803826 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -287,6 +287,25 @@ class SubprocessMixin:
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()