summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-11-30 02:21:41 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-11-30 02:21:41 (GMT)
commitafdd51343cafbc02443fa6f7a2166af951a67c64 (patch)
tree785c05f8dd519863ffc6f2c6ce1908387c5249f5 /Lib
parentc7217d7c2210008ba06e9bcb2a14439a451eef71 (diff)
downloadcpython-afdd51343cafbc02443fa6f7a2166af951a67c64.zip
cpython-afdd51343cafbc02443fa6f7a2166af951a67c64.tar.gz
cpython-afdd51343cafbc02443fa6f7a2166af951a67c64.tar.bz2
Issue #25764: Preserve subprocess fork exception when preexec_fn used
Also fix handling of failure to release the import lock.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_subprocess.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 2ce5951..188f337 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1416,6 +1416,22 @@ class POSIXProcessTestCase(BaseTestCase):
if not enabled:
gc.disable()
+ def test_preexec_fork_failure(self):
+ # The internal code did not preserve the previous exception when
+ # re-enabling garbage collection
+ try:
+ from resource import getrlimit, setrlimit, RLIMIT_NPROC
+ except ImportError as err:
+ self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD
+ limits = getrlimit(RLIMIT_NPROC)
+ [_, hard] = limits
+ setrlimit(RLIMIT_NPROC, (0, hard))
+ self.addCleanup(setrlimit, RLIMIT_NPROC, limits)
+ # Forking should raise EAGAIN, translated to BlockingIOError
+ with self.assertRaises(BlockingIOError):
+ subprocess.call([sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+
def test_args_string(self):
# args is a string
fd, fname = tempfile.mkstemp()