From 9ad4e771fca8fb2dbb62a20fa46acf971800a0b9 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 30 Dec 2008 14:13:27 +0100 Subject: [PATCH] fix exec statement in Py3 --- Cython/Compiler/Builtin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Builtin.py b/Cython/Compiler/Builtin.py index 764f79d1..ba017409 100644 --- a/Cython/Compiler/Builtin.py +++ b/Cython/Compiler/Builtin.py @@ -181,7 +181,11 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) { 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."); @@ -189,7 +193,12 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) { } 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; -- 2.26.2