[Python-Dev] Showstopper
Guido van Rossum
guido@digicool.com
Sun, 15 Apr 2001 20:11:05 -0500
> /* Allocate the result tuple first. Believe it or not,
> * this allocation could trigger a garbage collection which
> * could resize the dict, which would invalidate the pointer
> * (ep) into the dict calculated below, or clear the dict.
> * So we have to do this first.
> */
> res = PyTuple_New(2);
> if (res == NULL)
> return NULL;
> if (mp->ma_used == 0) {
> PyErr_SetString(PyExc_KeyError,
> "popitem(): dictionary is empty");
> Py_DECREF(res);
> return NULL;
> }
Good catch -- checked in now!
--Guido van Rossum (home page: http://www.python.org/~guido/)