os.system: on Windows, avoid encoding the command and use the "wide" function: _wsystem

This commit is contained in:
Amaury Forgeot d'Arc 2007-11-20 01:52:14 +00:00
parent 9414015744
commit 90ebd3e0e9
1 changed files with 11 additions and 1 deletions

View File

@ -2540,12 +2540,22 @@ Execute the command (a string) in a subshell.");
static PyObject * static PyObject *
posix_system(PyObject *self, PyObject *args) posix_system(PyObject *self, PyObject *args)
{ {
char *command;
long sts; 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)) if (!PyArg_ParseTuple(args, "s:system", &command))
return NULL; return NULL;
#endif
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
return PyInt_FromLong(sts); return PyInt_FromLong(sts);
} }