diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-02-25 15:59:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 15:59:46 (GMT) |
commit | a24107b04c1277e3c1105f98aff5bfa3a98b33a0 (patch) | |
tree | 55aa5a700e08e3ba27b0361df2b1043be5c4701a /Modules/_threadmodule.c | |
parent | a180b007d96fe68b32f11dec720fbd0cd5b6758a (diff) | |
download | cpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.zip cpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.gz cpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.bz2 |
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r-- | Modules/_threadmodule.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index aacce69..73babaf 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -814,8 +814,11 @@ _ldict(localobject *self) return NULL; } - dummy = PyDict_GetItem(tdict, self->key); + dummy = PyDict_GetItemWithError(tdict, self->key); if (dummy == NULL) { + if (PyErr_Occurred()) { + return NULL; + } ldict = _local_create_dummy(self); if (ldict == NULL) return NULL; @@ -931,14 +934,17 @@ local_getattro(localobject *self, PyObject *name) (PyObject *)self, name, ldict, 0); /* Optimization: just look in dict ourselves */ - value = PyDict_GetItem(ldict, name); - if (value == NULL) - /* Fall back on generic to get __class__ and __dict__ */ - return _PyObject_GenericGetAttrWithDict( - (PyObject *)self, name, ldict, 0); - - Py_INCREF(value); - return value; + value = PyDict_GetItemWithError(ldict, name); + if (value != NULL) { + Py_INCREF(value); + return value; + } + else if (PyErr_Occurred()) { + return NULL; + } + /* Fall back on generic to get __class__ and __dict__ */ + return _PyObject_GenericGetAttrWithDict( + (PyObject *)self, name, ldict, 0); } /* Called when a dummy is destroyed. */ @@ -958,7 +964,7 @@ _localdummy_destroyed(PyObject *localweakref, PyObject *dummyweakref) self = (localobject *) obj; if (self->dummies != NULL) { PyObject *ldict; - ldict = PyDict_GetItem(self->dummies, dummyweakref); + ldict = PyDict_GetItemWithError(self->dummies, dummyweakref); if (ldict != NULL) { PyDict_DelItem(self->dummies, dummyweakref); } |