diff options
author | Guido van Rossum <guido@python.org> | 2001-05-02 15:13:44 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-05-02 15:13:44 (GMT) |
commit | b1f35bffe5f2ce456854d4e8c8075a0d58e8eb02 (patch) | |
tree | 8ac7d314d24fca271fefc0f97107d1f2a44850b7 /Objects | |
parent | 542fe56cb9ed36bd8af8bd5cbfba9cdc7f3514f0 (diff) | |
download | cpython-b1f35bffe5f2ce456854d4e8c8075a0d58e8eb02.zip cpython-b1f35bffe5f2ce456854d4e8c8075a0d58e8eb02.tar.gz cpython-b1f35bffe5f2ce456854d4e8c8075a0d58e8eb02.tar.bz2 |
Mchael Hudson pointed out that the code for detecting changes in
dictionary size was comparing ma_size, the hash table size, which is
always a power of two, rather than ma_used, wich changes on each
insertion or deletion. Fixed this.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/dictobject.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index b374aeb..96d779d 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1479,7 +1479,7 @@ extern PyTypeObject PyDictIter_Type; /* Forward */ typedef struct { PyObject_HEAD dictobject *di_dict; - int di_size; + int di_used; int di_pos; binaryfunc di_select; } dictiterobject; @@ -1493,7 +1493,7 @@ dictiter_new(dictobject *dict, binaryfunc select) return NULL; Py_INCREF(dict); di->di_dict = dict; - di->di_size = dict->ma_size; + di->di_used = dict->ma_used; di->di_pos = 0; di->di_select = select; return (PyObject *)di; @@ -1511,7 +1511,7 @@ dictiter_next(dictiterobject *di, PyObject *args) { PyObject *key, *value; - if (di->di_size != di->di_dict->ma_size) { + if (di->di_used != di->di_dict->ma_used) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); return NULL; @@ -1546,7 +1546,7 @@ static PyObject *dictiter_iternext(dictiterobject *di) { PyObject *key, *value; - if (di->di_size != di->di_dict->ma_size) { + if (di->di_used != di->di_dict->ma_used) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); return NULL; |