Make cPickle use the recently-added PyInstance_NewRaw() API to create

instance objects without calling the constructor.  This is the same as
the new.instance() function.
This commit is contained in:
Fred Drake 2001-03-22 17:52:17 +00:00
parent 53f5968f9b
commit 2c77355937

View File

@ -2922,20 +2922,12 @@ Instance_New(PyObject *cls, PyObject *args) {
UNLESS (__getinitargs__=PyObject_GetAttr(cls, __getinitargs___str)) { UNLESS (__getinitargs__=PyObject_GetAttr(cls, __getinitargs___str)) {
/* We have a class with no __getinitargs__, so bypass usual /* We have a class with no __getinitargs__, so bypass usual
construction */ construction */
PyInstanceObject *inst; PyObject *inst;
PyErr_Clear(); PyErr_Clear();
UNLESS (inst=PyObject_New(PyInstanceObject, &PyInstance_Type)) UNLESS (inst=PyInstance_NewRaw(cls, NULL))
goto err; goto err;
inst->in_class=(PyClassObject*)cls; return inst;
Py_INCREF(cls);
UNLESS (inst->in_dict=PyDict_New()) {
inst = (PyInstanceObject *) PyObject_AS_GC(inst);
PyObject_DEL(inst);
goto err;
}
PyObject_GC_Init(inst);
return (PyObject *)inst;
} }
Py_DECREF(__getinitargs__); Py_DECREF(__getinitargs__);
} }