summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/posixmodule.c17
2 files changed, 14 insertions, 6 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 536ea43ed5..1a6d17ade1 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -184,6 +184,9 @@ Core and Builtins
Library
-------
+- Issue #8412: os.system() now accepts bytes, bytearray and str with
+ surrogates.
+
- Issue #4282: Fix the main function of the profile module for a non-ASCII
script, open the file in binary mode and not in text mode with the default
(utf8) encoding.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 502bf62a27..bba75aff48 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2814,18 +2814,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