diff options
author | Raymond Hettinger <python@rcn.com> | 2004-04-12 18:10:01 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-04-12 18:10:01 (GMT) |
commit | 7892b1c651d72a5bd08372f40309dec08a7065f0 (patch) | |
tree | 7ae71a1e81651c4fa7f786ebfbdbc8364a41730e /Objects/dictobject.c | |
parent | 45d0b5cc44ffb6227a2379a39b00d480f253edd5 (diff) | |
download | cpython-7892b1c651d72a5bd08372f40309dec08a7065f0.zip cpython-7892b1c651d72a5bd08372f40309dec08a7065f0.tar.gz cpython-7892b1c651d72a5bd08372f40309dec08a7065f0.tar.bz2 |
* Add unittests for iterators that report their length
* Document the differences between them
* Fix corner cases covered by the unittests
* Use Py_RETURN_NONE where possible for dictionaries
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r-- | Objects/dictobject.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 0f2a271..84cf482 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1088,10 +1088,9 @@ dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methnam static PyObject * dict_update(PyObject *self, PyObject *args, PyObject *kwds) { - if (dict_update_common(self, args, kwds, "update") == -1) - return NULL; - Py_INCREF(Py_None); - return Py_None; + if (dict_update_common(self, args, kwds, "update") != -1) + Py_RETURN_NONE; + return NULL; } /* Update unconditionally replaces existing items. @@ -1593,8 +1592,7 @@ static PyObject * dict_clear(register dictobject *mp) { PyDict_Clear((PyObject *)mp); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -2050,7 +2048,9 @@ dictiter_dealloc(dictiterobject *di) static int dictiter_len(dictiterobject *di) { - return di->len; + if (di->di_dict != NULL && di->di_used == di->di_dict->ma_used) + return di->len; + return 0; } static PySequenceMethods dictiter_as_sequence = { |