mirror of https://github.com/python/cpython
Merge 3.4 (asyncio)
This commit is contained in:
commit
a7a4c41411
|
@ -35,8 +35,13 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
|
||||||
self._pipes[2] = None
|
self._pipes[2] = None
|
||||||
|
|
||||||
# Create the child process: set the _proc attribute
|
# Create the child process: set the _proc attribute
|
||||||
self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
|
try:
|
||||||
stderr=stderr, bufsize=bufsize, **kwargs)
|
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._pid = self._proc.pid
|
||||||
self._extra['subprocess'] = self._proc
|
self._extra['subprocess'] = self._proc
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
import warnings
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
@ -413,6 +414,20 @@ class SubprocessMixin:
|
||||||
# the transport was not notified yet
|
# the transport was not notified yet
|
||||||
self.assertFalse(killed)
|
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':
|
if sys.platform != 'win32':
|
||||||
# Unix
|
# Unix
|
||||||
|
|
Loading…
Reference in New Issue