[Python-checkins] cpython (merge 3.4 -> 3.5): Merge 3.4 (asyncio)
victor.stinner
python-checkins at python.org
Fri Jul 31 17:51:26 CEST 2015
https://hg.python.org/cpython/rev/88c537e6d788
changeset: 97165:88c537e6d788
branch: 3.5
parent: 97161:3006f1e6a276
parent: 97164:f6b8a0c6b8c9
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Jul 31 17:50:13 2015 +0200
summary:
Merge 3.4 (asyncio)
files:
Lib/asyncio/base_subprocess.py | 9 +++++-
Lib/test/test_asyncio/test_subprocess.py | 15 ++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py
--- a/Lib/asyncio/base_subprocess.py
+++ b/Lib/asyncio/base_subprocess.py
@@ -35,8 +35,13 @@
self._pipes[2] = None
# Create the child process: set the _proc attribute
- self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
- stderr=stderr, bufsize=bufsize, **kwargs)
+ try:
+ self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
+ stderr=stderr, bufsize=bufsize, **kwargs)
+ except:
+ self.close()
+ raise
+
self._pid = self._proc.pid
self._extra['subprocess'] = self._proc
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -1,6 +1,7 @@
import signal
import sys
import unittest
+import warnings
from unittest import mock
import asyncio
@@ -413,6 +414,20 @@
# the transport was not notified yet
self.assertFalse(killed)
+ def test_popen_error(self):
+ # Issue #24763: check that the subprocess transport is closed
+ # when BaseSubprocessTransport fails
+ with mock.patch('subprocess.Popen') as popen:
+ exc = ZeroDivisionError
+ popen.side_effect = exc
+
+ create = asyncio.create_subprocess_exec(sys.executable, '-c',
+ 'pass', loop=self.loop)
+ with warnings.catch_warnings(record=True) as warns:
+ with self.assertRaises(exc):
+ self.loop.run_until_complete(create)
+ self.assertEqual(warns, [])
+
if sys.platform != 'win32':
# Unix
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list