[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.121,2.122
Guido van Rossum
gvanrossum@users.sourceforge.net
2001年12月05日 11:46:44 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv4883/Objects
Modified Files:
typeobject.c
Log Message:
At the PythonLabs meeting someone mentioned it would make Jim really
happy if one could delete the __dict__ attribute of an instance. I
love to make Jim happy, so here goes...
- New-style objects now support deleting their __dict__. This is for
all intents and purposes equivalent to assigning a brand new empty
dictionary, but saves space if the object is not used further.
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.121
retrieving revision 2.122
diff -C2 -d -r2.121 -r2.122
*** typeobject.c 2001年12月04日 17:13:22 2.121
--- typeobject.c 2001年12月05日 19:46:42 2.122
***************
*** 813,817 ****
return -1;
}
! if (value == NULL || !PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__dict__ must be set to a dictionary");
--- 813,817 ----
return -1;
}
! if (value != NULL && !PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__dict__ must be set to a dictionary");
***************
*** 819,823 ****
}
dict = *dictptr;
! Py_INCREF(value);
*dictptr = value;
Py_XDECREF(dict);
--- 819,823 ----
}
dict = *dictptr;
! Py_XINCREF(value);
*dictptr = value;
Py_XDECREF(dict);