summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-03-22 17:52:17 (GMT)
committerFred Drake <fdrake@acm.org>2001-03-22 17:52:17 (GMT)
commit2c7735593766e948036c2c714b4b2c41542f9743 (patch)
tree5cf079ef2100b6921cd5c0a38a7fd91b9678a037 /Modules
parent53f5968f9be616e1818fe831e012d917dd225ad7 (diff)
downloadcpython-2c7735593766e948036c2c714b4b2c41542f9743.zip
cpython-2c7735593766e948036c2c714b4b2c41542f9743.tar.gz
cpython-2c7735593766e948036c2c714b4b2c41542f9743.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cPickle.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 405456d..92325b6 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -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__);
}