diff -r ef3b3f026a51 Objects/typeobject.c --- a/Objects/typeobject.c Fri Nov 30 17:35:48 2012 +0100 +++ b/Objects/typeobject.c Fri Nov 30 18:57:54 2012 +0100 @@ -2387,6 +2387,15 @@ #include "typeslots.inc" }; +static PyObject * +PyObject_FailingNew(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyErr_Format(PyExc_TypeError, + "cannot create '%.100s' instances", + type->tp_name); + return NULL; +} + PyObject * PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) { @@ -2395,7 +2404,7 @@ char *s; char *res_start = (char*)res; PyType_Slot *slot; - + /* Set the type name and qualname */ s = strrchr(spec->name, '.'); if (s == NULL) @@ -2416,7 +2425,7 @@ type->tp_name = spec->name; if (!type->tp_name) goto fail; - + /* Adjust for empty tuple bases */ if (!bases) { base = &PyBaseObject_Type; @@ -2449,6 +2458,10 @@ goto fail; } + if(!type->tp_new){ + type->tp_new = PyObject_FailingNew; + } + /* Initialize essential fields */ type->tp_as_number = &res->as_number; type->tp_as_sequence = &res->as_sequence;