summaryrefslogtreecommitdiff
path: root/Lib/asyncio/subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/subprocess.py')
-rw-r--r--Lib/asyncio/subprocess.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py
index cd10231f71..50727ca300 100644
--- a/Lib/asyncio/subprocess.py
+++ b/Lib/asyncio/subprocess.py
@@ -144,10 +144,11 @@ class Process:
async def _feed_stdin(self, input):
debug = self._loop.get_debug()
- self.stdin.write(input)
- if debug:
- logger.debug(
- '%r communicate: feed stdin (%s bytes)', self, len(input))
+ if input is not None:
+ self.stdin.write(input)
+ if debug:
+ logger.debug(
+ '%r communicate: feed stdin (%s bytes)', self, len(input))
try:
await self.stdin.drain()
except (BrokenPipeError, ConnectionResetError) as exc:
@@ -180,7 +181,7 @@ class Process:
return output
async def communicate(self, input=None):
- if input is not None:
+ if self.stdin is not None:
stdin = self._feed_stdin(input)
else:
stdin = self._noop()