mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Issue #8412: os.system() now accepts bytes, bytearray and str with
surrogates.
This commit is contained in:
parent
ad02d239ff
commit
cfa72789c4
2 changed files with 17 additions and 9 deletions
|
@ -2688,18 +2688,23 @@ posix_system(PyObject *self, PyObject *args)
|
|||
wchar_t *command;
|
||||
if (!PyArg_ParseTuple(args, "u:system", &command))
|
||||
return NULL;
|
||||
#else
|
||||
char *command;
|
||||
if (!PyArg_ParseTuple(args, "s:system", &command))
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
#ifdef MS_WINDOWS
|
||||
sts = _wsystem(command);
|
||||
#else
|
||||
sts = system(command);
|
||||
#endif
|
||||
Py_END_ALLOW_THREADS
|
||||
#else
|
||||
PyObject *command_obj;
|
||||
char *command;
|
||||
if (!PyArg_ParseTuple(args, "O&:system",
|
||||
PyUnicode_FSConverter, &command_obj))
|
||||
return NULL;
|
||||
|
||||
command = bytes2str(command_obj, 1);
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
sts = system(command);
|
||||
Py_END_ALLOW_THREADS
|
||||
release_bytes(command_obj);
|
||||
#endif
|
||||
return PyLong_FromLong(sts);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue