Commit cfa72789 authored by Victor Stinner's avatar Victor Stinner

Issue #8412: os.system() now accepts bytes, bytearray and str with

surrogates.
parent ad02d239
...@@ -312,6 +312,9 @@ C-API ...@@ -312,6 +312,9 @@ C-API
Library Library
------- -------
- Issue #8412: os.system() now accepts bytes, bytearray and str with
surrogates.
- Issue #2987: RFC2732 support for urlparse (IPv6 addresses). Patch by Tony - Issue #2987: RFC2732 support for urlparse (IPv6 addresses). Patch by Tony
Locke and Hans Ulrich Niedermann. Locke and Hans Ulrich Niedermann.
......
...@@ -2688,18 +2688,23 @@ posix_system(PyObject *self, PyObject *args) ...@@ -2688,18 +2688,23 @@ posix_system(PyObject *self, PyObject *args)
wchar_t *command; wchar_t *command;
if (!PyArg_ParseTuple(args, "u:system", &command)) if (!PyArg_ParseTuple(args, "u:system", &command))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS
sts = _wsystem(command);
Py_END_ALLOW_THREADS
#else #else
PyObject *command_obj;
char *command; char *command;
if (!PyArg_ParseTuple(args, "s:system", &command)) if (!PyArg_ParseTuple(args, "O&:system",
PyUnicode_FSConverter, &command_obj))
return NULL; return NULL;
#endif
command = bytes2str(command_obj, 1);
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
#ifdef MS_WINDOWS
sts = _wsystem(command);
#else
sts = system(command); sts = system(command);
#endif
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
release_bytes(command_obj);
#endif
return PyLong_FromLong(sts); return PyLong_FromLong(sts);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment