diff -r 2dd106799aa9 Lib/test/test_os.py --- a/Lib/test/test_os.py Wed Oct 26 21:29:54 2011 +0300 +++ b/Lib/test/test_os.py Wed Oct 26 23:28:54 2011 +0400 @@ -1604,6 +1604,15 @@ self._check_xattrs(getxattr, setxattr, removexattr, listxattr) +@unittest.skipUnless(hasattr(os, 'spawnv'), + "no spawnv system call available") +class SpawnTests(unittest.TestCase): + def test_wrong_args(self): + self.assertRaises(ValueError, os.spawnl, os.P_WAIT, '') + self.assertRaises(ValueError, os.spawnl, os.P_WAIT, '__not_existing_path__') + self.assertRaises(ValueError, os.spawnl, os.P_WAIT, '__not_existing_path__', '') + + @support.reap_threads def test_main(): support.run_unittest( @@ -1628,6 +1637,7 @@ TestSendfile, ProgramPriorityTests, ExtendedAttributeTests, + SpawnTests, ) if __name__ == "__main__": diff -r 2dd106799aa9 Modules/posixmodule.c --- a/Modules/posixmodule.c Wed Oct 26 21:29:54 2011 +0300 +++ b/Modules/posixmodule.c Wed Oct 26 23:28:54 2011 +0400 @@ -4265,6 +4265,18 @@ Py_DECREF(opath); return NULL; } + if(!path || !*path) { + PyErr_SetString(PyExc_ValueError, + "spawnv() path can't be empty"); + Py_DECREF(opath); + return NULL; + } + if(!argc) { + PyErr_SetString(PyExc_ValueError, + "spawnv() arg 2 container must be not empty"); + Py_DECREF(opath); + return NULL; + } argvlist = PyMem_NEW(char *, argc+1); if (argvlist == NULL) { @@ -4282,6 +4294,12 @@ return NULL; } } + if(!*(argvlist[0])) { + PyErr_SetString(PyExc_ValueError, + "first argument can't be empty"); + Py_DECREF(opath); + return NULL; + } argvlist[argc] = NULL; #if defined(PYOS_OS2) && defined(PYCC_GCC)