]> granicus.if.org Git - python/commitdiff
os.system: on Windows, avoid encoding the command and use the "wide" function: _wsystem
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 20 Nov 2007 01:52:14 +0000 (01:52 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 20 Nov 2007 01:52:14 +0000 (01:52 +0000)
Modules/posixmodule.c

index 9d7fe238c5fc7e9640e0e6eeebd291c33b2a7740..27efcd38d426f797a7968133a02dad7422f0c28c 100644 (file)
@@ -2540,12 +2540,22 @@ Execute the command (a string) in a subshell.");
 static PyObject *
 posix_system(PyObject *self, PyObject *args)
 {
-       char *command;
        long sts;
+#ifdef MS_WINDOWS
+       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
        return PyInt_FromLong(sts);
 }