summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-04-16 11:45:13 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-04-16 11:45:13 (GMT)
commitcfa72789c4c38620f05170694ebc21bb61837155 (patch)
treef4d430cc7349ca988c6cb6d298b248d236d08e6e /Modules/posixmodule.c
parentad02d239ffc247c6f4ccafaa1428d47465f178ef (diff)
downloadcpython-cfa72789c4c38620f05170694ebc21bb61837155.zip
cpython-cfa72789c4c38620f05170694ebc21bb61837155.tar.gz
cpython-cfa72789c4c38620f05170694ebc21bb61837155.tar.bz2
Issue #8412: os.system() now accepts bytes, bytearray and str with
surrogates.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e6ef410..fb22eb6 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2688,18 +2688,23 @@ posix_system(PyObject *self, PyObject *args)
wchar_t *command;
if (!PyArg_ParseTuple(args, "u:system", &command))
return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ sts = _wsystem(command);
+ Py_END_ALLOW_THREADS
#else
+ PyObject *command_obj;
char *command;
- if (!PyArg_ParseTuple(args, "s:system", &command))
+ if (!PyArg_ParseTuple(args, "O&:system",
+ PyUnicode_FSConverter, &command_obj))
return NULL;
-#endif
+
+ command = bytes2str(command_obj, 1);
Py_BEGIN_ALLOW_THREADS
-#ifdef MS_WINDOWS
- sts = _wsystem(command);
-#else
sts = system(command);
-#endif
Py_END_ALLOW_THREADS
+ release_bytes(command_obj);
+#endif
return PyLong_FromLong(sts);
}
#endif