bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)

Only AttributeError should be silenced.
This commit is contained in:
Serhiy Storchaka 2019-09-01 12:03:39 +03:00 committed by GitHub
parent f02ea6225b
commit 41c57b3353
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 134 additions and 127 deletions

View file

@ -3607,24 +3607,24 @@ tzinfo_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
_Py_IDENTIFIER(__getinitargs__);
_Py_IDENTIFIER(__getstate__);
getinitargs = _PyObject_GetAttrId(self, &PyId___getinitargs__);
if (_PyObject_LookupAttrId(self, &PyId___getinitargs__, &getinitargs) < 0) {
return NULL;
}
if (getinitargs != NULL) {
args = PyObject_CallNoArgs(getinitargs);
Py_DECREF(getinitargs);
if (args == NULL) {
return NULL;
}
}
else {
PyErr_Clear();
args = PyTuple_New(0);
if (args == NULL) {
return NULL;
}
}
if (args == NULL) {
return NULL;
}
getstate = _PyObject_GetAttrId(self, &PyId___getstate__);
if (_PyObject_LookupAttrId(self, &PyId___getstate__, &getstate) < 0) {
Py_DECREF(args);
return NULL;
}
if (getstate != NULL) {
state = PyObject_CallNoArgs(getstate);
Py_DECREF(getstate);
@ -3635,7 +3635,6 @@ tzinfo_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
}
else {
PyObject **dictptr;
PyErr_Clear();
state = Py_None;
dictptr = _PyObject_GetDictPtr(self);
if (dictptr && *dictptr && PyDict_GET_SIZE(*dictptr)) {