diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-04-24 18:44:18 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-04-24 18:44:18 (GMT) |
commit | 15ee821eb50b1d764fad358d7a9ce9f32813d4ee (patch) | |
tree | 9011c797637bcfb98719f9966dbe62500d401dfa /Objects | |
parent | 17feca0efc1bb49925f798a7de8eb164f5bdc98b (diff) | |
download | cpython-15ee821eb50b1d764fad358d7a9ce9f32813d4ee.zip cpython-15ee821eb50b1d764fad358d7a9ce9f32813d4ee.tar.gz cpython-15ee821eb50b1d764fad358d7a9ce9f32813d4ee.tar.bz2 |
distiguish between refusing to creating shared keys and error (#13903)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/dictobject.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 610a5ee..d08a40e 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -966,6 +966,8 @@ dictresize(PyDictObject *mp, Py_ssize_t minused) return 0; } +/* Returns NULL if unable to split table. + * A NULL return does not necessarily indicate an error */ static PyDictKeysObject * make_keys_shared(PyObject *op) { @@ -973,7 +975,8 @@ make_keys_shared(PyObject *op) Py_ssize_t size; PyDictObject *mp = (PyDictObject *)op; - assert(PyDict_CheckExact(op)); + if (!PyDict_CheckExact(op)) + return NULL; if (!_PyDict_HasSplitTable(mp)) { PyDictKeyEntry *ep0; PyObject **values; @@ -3694,14 +3697,14 @@ _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, res = PyDict_SetItem(dict, key, value); if (cached != ((PyDictObject *)dict)->ma_keys) { /* Either update tp->ht_cached_keys or delete it */ - if (cached->dk_refcnt == 1 && PyDict_CheckExact(dict)) { + if (cached->dk_refcnt == 1) { CACHED_KEYS(tp) = make_keys_shared(dict); - if (CACHED_KEYS(tp) == NULL) - return -1; } else { CACHED_KEYS(tp) = NULL; } DK_DECREF(cached); + if (CACHED_KEYS(tp) == NULL && PyErr_Occurred()) + return -1; } } } else { |