Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6f33e294
Commit
6f33e294
authored
Nov 19, 2016
by
Steve Dower
Browse files
Options
Browse Files
Download
Plain Diff
Issue #28732: Raise ValueError when os.spawn*() is passed an empty tuple of arguments
parents
1325ee09
859fd7bd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
Lib/test/test_os.py
Lib/test/test_os.py
+21
-0
Modules/posixmodule.c
Modules/posixmodule.c
+10
-0
No files found.
Lib/test/test_os.py
View file @
6f33e294
...
@@ -2321,6 +2321,27 @@ class SpawnTests(unittest.TestCase):
...
@@ -2321,6 +2321,27 @@ class SpawnTests(unittest.TestCase):
exitcode
=
os
.
spawnve
(
os
.
P_WAIT
,
args
[
0
],
args
,
self
.
env
)
exitcode
=
os
.
spawnve
(
os
.
P_WAIT
,
args
[
0
],
args
,
self
.
env
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
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
# The introduction of this TestCase caused at least two different errors on
# *nix buildbots. Temporarily skip this to let the buildbots move along.
# *nix buildbots. Temporarily skip this to let the buildbots move along.
...
...
Modules/posixmodule.c
View file @
6f33e294
...
@@ -5042,6 +5042,11 @@ os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv)
...
@@ -5042,6 +5042,11 @@ os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv)
"spawnv() arg 2 must be a tuple or list"
);
"spawnv() arg 2 must be a tuple or list"
);
return
NULL
;
return
NULL
;
}
}
if
(
argc
==
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"spawnv() arg 2 cannot be empty"
);
return
NULL
;
}
argvlist
=
PyMem_NEW
(
EXECV_CHAR
*
,
argc
+
1
);
argvlist
=
PyMem_NEW
(
EXECV_CHAR
*
,
argc
+
1
);
if
(
argvlist
==
NULL
)
{
if
(
argvlist
==
NULL
)
{
...
@@ -5127,6 +5132,11 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
...
@@ -5127,6 +5132,11 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
"spawnve() arg 2 must be a tuple or list"
);
"spawnve() arg 2 must be a tuple or list"
);
goto
fail_0
;
goto
fail_0
;
}
}
if
(
argc
==
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"spawnve() arg 2 cannot be empty"
);
goto
fail_0
;
}
if
(
!
PyMapping_Check
(
env
))
{
if
(
!
PyMapping_Check
(
env
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"spawnve() arg 3 must be a mapping object"
);
"spawnve() arg 3 must be a mapping object"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment