[Python-checkins] cpython (3.6): Issue #28732: Raise ValueError when os.spawn*() is passed an empty tuple of
steve.dower
python-checkins at python.org
Sat Nov 19 21:53:44 EST 2016
https://hg.python.org/cpython/rev/1a9e4b465497
changeset: 105194:1a9e4b465497
branch: 3.6
parent: 105192:b3a6cc610ee4
user: Steve Dower <steve.dower at microsoft.com>
date: Sat Nov 19 18:53:19 2016 -0800
summary:
Issue #28732: Raise ValueError when os.spawn*() is passed an empty tuple of arguments
files:
Lib/test/test_os.py | 21 +++++++++++++++++++++
Modules/posixmodule.c | 10 ++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -2321,6 +2321,27 @@
exitcode = os.spawnve(os.P_WAIT, args[0], args, self.env)
self.assertEqual(exitcode, self.exitcode)
+ @requires_os_func('spawnl')
+ def test_spawnl_noargs(self):
+ args = self.create_args()
+ self.assertRaises(ValueError, os.spawnl, os.P_NOWAIT, args[0])
+
+ @requires_os_func('spawnle')
+ def test_spawnl_noargs(self):
+ args = self.create_args()
+ self.assertRaises(ValueError, os.spawnle, os.P_NOWAIT, args[0], {})
+
+ @requires_os_func('spawnv')
+ def test_spawnv_noargs(self):
+ args = self.create_args()
+ self.assertRaises(ValueError, os.spawnv, os.P_NOWAIT, args[0], ())
+ self.assertRaises(ValueError, os.spawnv, os.P_NOWAIT, args[0], [])
+
+ @requires_os_func('spawnve')
+ def test_spawnv_noargs(self):
+ args = self.create_args()
+ self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, args[0], (), {})
+ self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, args[0], [], {})
# The introduction of this TestCase caused at least two different errors on
# *nix buildbots. Temporarily skip this to let the buildbots move along.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5042,6 +5042,11 @@
"spawnv() arg 2 must be a tuple or list");
return NULL;
}
+ if (argc == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "spawnv() arg 2 cannot be empty");
+ return NULL;
+ }
argvlist = PyMem_NEW(EXECV_CHAR *, argc+1);
if (argvlist == NULL) {
@@ -5127,6 +5132,11 @@
"spawnve() arg 2 must be a tuple or list");
goto fail_0;
}
+ if (argc == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "spawnve() arg 2 cannot be empty");
+ goto fail_0;
+ }
if (!PyMapping_Check(env)) {
PyErr_SetString(PyExc_TypeError,
"spawnve() arg 3 must be a mapping object");
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list