('dir', "O", "O", "PyObject_Dir"),
('divmod', "OO", "O", "PyNumber_Divmod"),
('exec', "OOO", "O", "__Pyx_PyRun"),
+ ('exec', "OO", "O", "__Pyx_PyRun2"),
#('eval', "", "", ""),
#('execfile', "", "", ""),
#('filter', "", "", ""),
#endif
#endif
static PyObject* __Pyx_PyRun(PyObject*, PyObject*, PyObject*);
+static CYTHON_INLINE PyObject* __Pyx_PyRun2(PyObject*, PyObject*);
""",
impl = """
+static CYTHON_INLINE PyObject* __Pyx_PyRun2(PyObject* o, PyObject* globals) {
+ return __Pyx_PyRun(o, globals, NULL);
+}
+
static PyObject* __Pyx_PyRun(PyObject* o, PyObject* globals, PyObject* locals) {
PyObject* result;
PyObject* s = 0;
self.error("Unrecognized character")
if sy == IDENT:
if systring in self.keywords:
- if systring == 'print' and \
- print_function in self.context.future_directives:
+ if systring == 'print' and print_function in self.context.future_directives:
+ self.keywords.remove('print')
+ systring = EncodedString(systring)
+ elif systring == 'exec' and self.context.language_level >= 3:
+ self.keywords.remove('exec')
systring = EncodedString(systring)
else:
sy = systring
"""
print(*args) # this isn't valid Py2 syntax
+def exec3_function(cmd):
+ """
+ >>> exec3_function('a = 1+1')['a']
+ 2
+ """
+ g = {}
+ l = {}
+ exec(cmd, g, l)
+ return l
+
+def exec2_function(cmd):
+ """
+ >>> exec2_function('a = 1+1')['a']
+ 2
+ """
+ g = {}
+ exec(cmd, g)
+ return g
+
ustring = "abcdefg"
def unicode_literals():