s = PyUnicode_AsUTF8String(o);
if (!s) goto bad;
o = s;
+ #if PY_MAJOR_VERSION >= 3
+ } else if (!PyBytes_Check(o)) {
+ #else
} else if (!PyString_Check(o)) {
+ #endif
/* FIXME: support file objects and code objects */
PyErr_SetString(PyExc_TypeError,
"exec currently requires a string as code input.");
}
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);
return result;