Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asyncio/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _read_stream(self, fd):

@coroutine
def communicate(self, input=None):
if input:
if input is not None:
stdin = self._feed_stdin(input)
else:
stdin = self._noop()
Expand Down
19 changes: 19 additions & 0 deletions tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,25 @@ def len_message(message):
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()

Expand Down