Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
5bb27ff1
Commit
5bb27ff1
authored
Aug 19, 2009
by
Andrey Plotnikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code object support in exec statement
parent
a5e49f6e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
+27
-20
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+27
-20
No files found.
Cython/Compiler/Builtin.py
View file @
5bb27ff1
...
@@ -182,27 +182,34 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) {
...
@@ -182,27 +182,34 @@ static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) {
globals = locals;
globals = locals;
}
}
if (PyUnicode_Check(o)) {
if (PyDict_GetItemString(globals, "__builtins__") == NULL) {
s = PyUnicode_AsUTF8String(o);
PyDict_SetItemString(globals, "__builtins__", PyEval_GetBuiltins());
if (!s) goto bad;
}
o = s;
#if PY_MAJOR_VERSION >= 3
if (PyCode_Check(o)) {
} else if (!PyBytes_Check(o)) {
result = PyEval_EvalCode((PyCodeObject *)o, globals, locals);
#else
}
} else if (!PyString_Check(o)) {
else {
#endif
if (PyUnicode_Check(o)) {
/* FIXME: support file objects and code objects */
s = PyUnicode_AsUTF8String(o);
PyErr_SetString(PyExc_TypeError,
if (!s) goto bad;
"exec currently requires a string as code input.");
o = s;
goto bad;
#if PY_MAJOR_VERSION >= 3
} else if (!PyBytes_Check(o)) {
#else
} else if (!PyString_Check(o)) {
#endif
PyErr_SetString(PyExc_TypeError,
"exec: arg 1 must be string, bytes or code object");
goto bad;
}
#if PY_MAJOR_VERSION >= 3
code = PyBytes_AS_STRING(o);
#else
code = PyString_AS_STRING(o);
#endif
result = PyRun_String(code, Py_file_input, globals, locals);
}
}
#if PY_MAJOR_VERSION >= 3
code = PyBytes_AS_STRING(o);
#else
code = PyString_AS_STRING(o);
#endif
result = PyRun_String(code, Py_file_input, globals, locals);
Py_XDECREF(s);
Py_XDECREF(s);
return result;
return result;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment