diff Python/bltinmodule.c @ 83791:6db3741e59be

rather than passing locals to the class body, just execute the class body in the proper environment
author Benjamin Peterson <benjamin@python.org>
date Thu, 16 May 2013 14:37:25 -0500
parents cc59c215f19e
children 76196691b5d0
line wrap: on
line diff
--- a/Python/bltinmodule.c	Thu May 16 12:03:40 2013 -0500
+++ b/Python/bltinmodule.c	Thu May 16 14:37:25 2013 -0500
@@ -57,6 +57,11 @@
         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 @@
         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);