mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
This commit is contained in:
parent
f02ea6225b
commit
41c57b3353
14 changed files with 134 additions and 127 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue