Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
bce26262
Kaydet (Commit)
bce26262
authored
Kas 20, 2016
tarafından
Steve Dower
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #28732: Raise ValueError when argv[0] is empty
üst
859fd7bd
93ff8725
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
2 deletions
+50
-2
test_os.py
Lib/test/test_os.py
+16
-2
posixmodule.c
Modules/posixmodule.c
+34
-0
No files found.
Lib/test/test_os.py
Dosyayı görüntüle @
bce26262
...
...
@@ -1481,8 +1481,16 @@ class ExecTests(unittest.TestCase):
self
.
assertRaises
(
OSError
,
os
.
execvpe
,
'no such app-'
,
[
'no such app-'
],
None
)
def
test_execv_with_bad_arglist
(
self
):
self
.
assertRaises
(
ValueError
,
os
.
execv
,
'notepad'
,
())
self
.
assertRaises
(
ValueError
,
os
.
execv
,
'notepad'
,
[])
self
.
assertRaises
(
ValueError
,
os
.
execv
,
'notepad'
,
(
''
,))
self
.
assertRaises
(
ValueError
,
os
.
execv
,
'notepad'
,
[
''
])
def
test_execvpe_with_bad_arglist
(
self
):
self
.
assertRaises
(
ValueError
,
os
.
execvpe
,
'notepad'
,
[],
None
)
self
.
assertRaises
(
ValueError
,
os
.
execvpe
,
'notepad'
,
[],
{})
self
.
assertRaises
(
ValueError
,
os
.
execvpe
,
'notepad'
,
[
''
],
{})
@unittest.skipUnless
(
hasattr
(
os
,
'_execvpe'
),
"No internal os._execvpe function to test."
)
...
...
@@ -2325,23 +2333,29 @@ class SpawnTests(unittest.TestCase):
def
test_spawnl_noargs
(
self
):
args
=
self
.
create_args
()
self
.
assertRaises
(
ValueError
,
os
.
spawnl
,
os
.
P_NOWAIT
,
args
[
0
])
self
.
assertRaises
(
ValueError
,
os
.
spawnl
,
os
.
P_NOWAIT
,
args
[
0
],
''
)
@requires_os_func
(
'spawnle'
)
def
test_spawnl_noargs
(
self
):
def
test_spawnl
e
_noargs
(
self
):
args
=
self
.
create_args
()
self
.
assertRaises
(
ValueError
,
os
.
spawnle
,
os
.
P_NOWAIT
,
args
[
0
],
{})
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
],
[])
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
):
def
test_spawnv
e
_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
],
[],
{})
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.
...
...
Modules/posixmodule.c
Dosyayı görüntüle @
bce26262
...
...
@@ -4916,12 +4916,20 @@ os_execv_impl(PyObject *module, path_t *path, PyObject *argv)
if (argvlist == NULL) {
return NULL;
}
if (!argvlist[0][0]) {
PyErr_SetString(PyExc_ValueError,
"execv() arg 2 first element cannot be empty");
free_string_array(argvlist, argc);
return NULL;
}
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_WEXECV
_wexecv(path->wide, argvlist);
#else
execv(path->narrow, argvlist);
#endif
_Py_END_SUPPRESS_IPH
/* If we get here it's definitely an error */
...
...
@@ -4961,6 +4969,11 @@ os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env)
goto fail;
}
argc = PySequence_Size(argv);
if (argc < 1) {
PyErr_SetString(PyExc_ValueError, "execve: argv must not be empty");
return NULL;
}
if (!PyMapping_Check(env)) {
PyErr_SetString(PyExc_TypeError,
"execve: environment must be a mapping object");
...
...
@@ -4971,11 +4984,17 @@ os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env)
if (argvlist == NULL) {
goto fail;
}
if (!argvlist[0][0]) {
PyErr_SetString(PyExc_ValueError,
"execve: argv first element cannot be empty");
goto fail;
}
envlist = parse_envlist(env, &envc);
if (envlist == NULL)
goto fail;
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_FEXECVE
if (path->fd > -1)
fexecve(path->fd, argvlist, envlist);
...
...
@@ -4986,6 +5005,7 @@ os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env)
#else
execve(path->narrow, argvlist, envlist);
#endif
_Py_END_SUPPRESS_IPH
/* If we get here it's definitely an error */
...
...
@@ -5061,6 +5081,13 @@ os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv)
"spawnv() arg 2 must contain only strings");
return NULL;
}
if (i == 0 && !argvlist[0][0]) {
free_string_array(argvlist, i);
PyErr_SetString(
PyExc_ValueError,
"spawnv() arg 2 first element cannot be empty");
return NULL;
}
}
argvlist[argc] = NULL;
...
...
@@ -5155,6 +5182,13 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
lastarg = i;
goto fail_1;
}
if (i == 0 && !argvlist[0][0]) {
lastarg = i;
PyErr_SetString(
PyExc_ValueError,
"spawnv() arg 2 first element cannot be empty");
goto fail_1;
}
}
lastarg = argc;
argvlist[argc] = NULL;
...
...
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