summaryrefslogtreecommitdiffstats
path: root/Modules/_datetimemodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-01 09:03:39 (GMT)
committerGitHub <noreply@github.com>2019-09-01 09:03:39 (GMT)
commit41c57b335330ff48af098d47e379e0f9ba09d233 (patch)
tree15cdef099182eddb04b2276dc51375b8faf28278 /Modules/_datetimemodule.c
parentf02ea6225bc3b71bd5fe66224d199a6e3e23b14d (diff)
downloadcpython-41c57b335330ff48af098d47e379e0f9ba09d233.zip
cpython-41c57b335330ff48af098d47e379e0f9ba09d233.tar.gz
cpython-41c57b335330ff48af098d47e379e0f9ba09d233.tar.bz2
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r--Modules/_datetimemodule.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 8f4fa21..c1b2407 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -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)) {