diff options
| author | Guido van Rossum <guido@python.org> | 2001-12-05 19:46:42 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2001-12-05 19:46:42 +0000 |
| commit | d331cb550221cbf0a5863968ed272fb2afc90202 (patch) | |
| tree | 55cd126e9bd86860463f2dd440f9dff890e25db5 /Objects | |
| parent | 698da02d3b0ce3364dc4e9bd61a47d73ca4e74a7 (diff) | |
| download | cpython-git-d331cb550221cbf0a5863968ed272fb2afc90202.tar.gz | |
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.
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/typeobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 16591cf77f..14a7e86c81 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -812,13 +812,13 @@ subtype_setdict(PyObject *obj, PyObject *value, void *context) "This object has no __dict__"); return -1; } - if (value == NULL || !PyDict_Check(value)) { + if (value != NULL && !PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__dict__ must be set to a dictionary"); return -1; } dict = *dictptr; - Py_INCREF(value); + Py_XINCREF(value); *dictptr = value; Py_XDECREF(dict); return 0; |
