summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-02 16:48:17 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-02 16:48:17 (GMT)
commit4737482fada222f2353b9abc9bcf14bfac49fb79 (patch)
treeb015be13b0bf0c7b556a745d58e23dddf657b767 /Objects
parenta9efc8e2684a04ae37c1528fd8f079247b6a0536 (diff)
downloadcpython-4737482fada222f2353b9abc9bcf14bfac49fb79.zip
cpython-4737482fada222f2353b9abc9bcf14bfac49fb79.tar.gz
cpython-4737482fada222f2353b9abc9bcf14bfac49fb79.tar.bz2
Add a default __prepare__() method to 'type', so it can be called
using super(). (See recent conversation on python-3000 with Talin and Phillip Eby about PEP 3115 chaining rules.)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 3ad5efc..8cf28fc 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2200,11 +2200,21 @@ type_subclasses(PyTypeObject *type, PyObject *args_ignored)
return list;
}
+static PyObject *
+type_prepare(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ return PyDict_New();
+}
+
static PyMethodDef type_methods[] = {
{"mro", (PyCFunction)mro_external, METH_NOARGS,
PyDoc_STR("mro() -> list\nreturn a type's method resolution order")},
{"__subclasses__", (PyCFunction)type_subclasses, METH_NOARGS,
PyDoc_STR("__subclasses__() -> list of immediate subclasses")},
+ {"__prepare__", (PyCFunction)type_prepare,
+ METH_VARARGS | METH_KEYWORDS | METH_CLASS,
+ PyDoc_STR("__prepare__() -> dict\n"
+ "used to create the namespace for the class statement")},
{0}
};