Make cPickle use the recently-added PyInstance_NewRaw() API to create
authorFred Drake <fdrake@acm.org>
Thu, 22 Mar 2001 17:52:17 +0000 (17:52 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 22 Mar 2001 17:52:17 +0000 (17:52 +0000)
instance objects without calling the constructor.  This is the same as
the new.instance() function.

Modules/cPickle.c

index 405456d480550181ec0781b62f2b23da36d82715..92325b67301ebcc5fddd4ee11bfc7afe8acd4a68 100644 (file)
@@ -2922,20 +2922,12 @@ Instance_New(PyObject *cls, PyObject *args) {
           UNLESS (__getinitargs__=PyObject_GetAttr(cls, __getinitargs___str)) {
               /* We have a class with no __getinitargs__, so bypass usual
                  construction  */
-              PyInstanceObject *inst;
+              PyObject *inst;
 
               PyErr_Clear();
-              UNLESS (inst=PyObject_New(PyInstanceObject, &PyInstance_Type))
+              UNLESS (inst=PyInstance_NewRaw(cls, NULL))
                 goto err;
-              inst->in_class=(PyClassObject*)cls;
-              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;
+              return inst;
             }
           Py_DECREF(__getinitargs__);
         }