diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-05-16 19:37:25 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-05-16 19:37:25 (GMT) |
commit | e8e14591ebb729b4fa19626ce245fa0811cf6f32 (patch) | |
tree | 6448a655b30bd5f6d1f23137ebb5f8183547f109 /Python/bltinmodule.c | |
parent | e914123d1f07159f32bf4330556397ce4d590189 (diff) | |
download | cpython-e8e14591ebb729b4fa19626ce245fa0811cf6f32.zip cpython-e8e14591ebb729b4fa19626ce245fa0811cf6f32.tar.gz cpython-e8e14591ebb729b4fa19626ce245fa0811cf6f32.tar.bz2 |
rather than passing locals to the class body, just execute the class body in the proper environment
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 5291565..356bb50 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -57,6 +57,11 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) return NULL; } func = PyTuple_GET_ITEM(args, 0); /* Better be callable */ + if (!PyFunction_Check(func)) { + PyErr_SetString(PyExc_TypeError, + "__build__class__: func must be a function"); + return NULL; + } name = PyTuple_GET_ITEM(args, 1); if (!PyUnicode_Check(name)) { PyErr_SetString(PyExc_TypeError, @@ -155,7 +160,9 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) Py_DECREF(bases); return NULL; } - cell = PyObject_CallFunctionObjArgs(func, ns, NULL); + cell = PyEval_EvalCodeEx(PyFunction_GET_CODE(func), PyFunction_GET_GLOBALS(func), ns, + NULL, 0, NULL, 0, NULL, 0, NULL, + PyFunction_GET_CLOSURE(func)); if (cell != NULL) { PyObject *margs; margs = PyTuple_Pack(3, name, bases, ns); |