diff options
author | Gregory P. Smith <greg@krypto.org> | 2015-11-16 05:15:26 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2015-11-16 05:15:26 (GMT) |
commit | d0a5b1c3432574c248dfd86e583b5cd09503a374 (patch) | |
tree | c48f6cc1e71665862045e08a5e61830426ff44d6 /Lib/test | |
parent | 2cd1b3b08912133ff3d33755a9949c2aa0155b95 (diff) | |
download | cpython-d0a5b1c3432574c248dfd86e583b5cd09503a374.zip cpython-d0a5b1c3432574c248dfd86e583b5cd09503a374.tar.gz cpython-d0a5b1c3432574c248dfd86e583b5cd09503a374.tar.bz2 |
Fixes #23564: Fix a partially broken sanity check in the _posixsubprocess
internals regarding how fds_to_pass were passed to the child. The bug
had no actual impact as subprocess.py already avoided it.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_subprocess.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 5fd6526..e06beed 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -2312,8 +2312,6 @@ class POSIXProcessTestCase(BaseTestCase): func = lambda: None gc.enable() - executable_list = "exec" # error: must be a sequence - for args, exe_list, cwd, env_list in ( (123, [b"exe"], None, [b"env"]), ([b"arg"], 123, None, [b"env"]), @@ -2331,6 +2329,34 @@ class POSIXProcessTestCase(BaseTestCase): if not gc_enabled: gc.disable() + @support.cpython_only + def test_fork_exec_sorted_fd_sanity_check(self): + # Issue #23564: sanity check the fork_exec() fds_to_keep sanity check. + import _posixsubprocess + gc_enabled = gc.isenabled() + try: + gc.enable() + + for fds_to_keep in ( + (-1, 2, 3, 4, 5), # Negative number. + ('str', 4), # Not an int. + (18, 23, 42, 2**63), # Out of range. + (5, 4), # Not sorted. + (6, 7, 7, 8), # Duplicate. + ): + with self.assertRaises( + ValueError, + msg='fds_to_keep={}'.format(fds_to_keep)) as c: + _posixsubprocess.fork_exec( + [b"false"], [b"false"], + True, fds_to_keep, None, [b"env"], + -1, -1, -1, -1, + 1, 2, 3, 4, + True, True, None) + self.assertIn('fds_to_keep', str(c.exception)) + finally: + if not gc_enabled: + gc.disable() @unittest.skipUnless(mswindows, "Windows specific tests") |