Commit 9ad4e771 authored by Stefan Behnel's avatar Stefan Behnel

fix exec statement in Py3

parent 80b0fa4e
...@@ -181,7 +181,11 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) { ...@@ -181,7 +181,11 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) {
s = PyUnicode_AsUTF8String(o); s = PyUnicode_AsUTF8String(o);
if (!s) goto bad; if (!s) goto bad;
o = s; o = s;
#if PY_MAJOR_VERSION >= 3
} else if (!PyBytes_Check(o)) {
#else
} else if (!PyString_Check(o)) { } else if (!PyString_Check(o)) {
#endif
/* FIXME: support file objects and code objects */ /* FIXME: support file objects and code objects */
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"exec currently requires a string as code input."); "exec currently requires a string as code input.");
...@@ -189,7 +193,12 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) { ...@@ -189,7 +193,12 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) {
} }
result = PyRun_String( result = PyRun_String(
PyString_AS_STRING(o), Py_file_input, globals, locals); #if PY_MAJOR_VERSION >= 3
PyBytes_AS_STRING(o),
#else
PyString_AS_STRING(o),
#endif
Py_file_input, globals, locals);
Py_XDECREF(s); Py_XDECREF(s);
return result; return result;
......
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