diff -r 059489cec7b9 Objects/descrobject.c --- a/Objects/descrobject.c Thu Mar 22 02:09:08 2012 +0100 +++ b/Objects/descrobject.c Thu Mar 22 02:46:42 2012 +0100 @@ -839,9 +839,29 @@ proxy_richcompare(proxyobject *v, PyObje return PyObject_RichCompare(v->dict, w, op); } +static PyObject* +proxy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"dict", 0}; + PyObject *dict; + proxyobject *proxy; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:dictproxy", + kwlist, &dict)) + return NULL; + + proxy = PyObject_GC_New(proxyobject, &PyDictProxy_Type); + if (proxy == NULL) + return NULL; + Py_INCREF(dict); + proxy->dict = dict; + _PyObject_GC_TRACK(proxy); + return (PyObject *)proxy; +} + PyTypeObject PyDictProxy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "dict_proxy", /* tp_name */ + "dictproxy", /* tp_name */ sizeof(proxyobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ @@ -875,6 +895,10 @@ PyTypeObject PyDictProxy_Type = { 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + proxy_new, /* tp_new */ }; PyObject * @@ -891,7 +915,6 @@ PyDictProxy_New(PyObject *dict) return (PyObject *)pp; } - /* --- Wrapper object for "slot" methods --- */ /* This has no reason to be in this file except that adding new files is a diff -r 059489cec7b9 Python/bltinmodule.c --- a/Python/bltinmodule.c Thu Mar 22 02:09:08 2012 +0100 +++ b/Python/bltinmodule.c Thu Mar 22 02:46:42 2012 +0100 @@ -2393,6 +2393,7 @@ _PyBuiltin_Init(void) SETBUILTIN("classmethod", &PyClassMethod_Type); SETBUILTIN("complex", &PyComplex_Type); SETBUILTIN("dict", &PyDict_Type); + SETBUILTIN("dictproxy", &PyDictProxy_Type); SETBUILTIN("enumerate", &PyEnum_Type); SETBUILTIN("filter", &PyFilter_Type); SETBUILTIN("float", &PyFloat_Type);