summaryrefslogtreecommitdiff
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-01 12:03:39 +0300
committerGitHub <noreply@github.com>2019-09-01 12:03:39 +0300
commit41c57b335330ff48af098d47e379e0f9ba09d233 (patch)
tree15cdef099182eddb04b2276dc51375b8faf28278 /Objects/fileobject.c
parentf02ea6225bc3b71bd5fe66224d199a6e3e23b14d (diff)
downloadcpython-git-41c57b335330ff48af098d47e379e0f9ba09d233.tar.gz
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 0faf7e70b5..61c9428093 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -185,8 +185,10 @@ PyObject_AsFileDescriptor(PyObject *o)
if (PyLong_Check(o)) {
fd = _PyLong_AsInt(o);
}
- else if ((meth = _PyObject_GetAttrId(o, &PyId_fileno)) != NULL)
- {
+ else if (_PyObject_LookupAttrId(o, &PyId_fileno, &meth) < 0) {
+ return -1;
+ }
+ else if (meth != NULL) {
PyObject *fno = _PyObject_CallNoArg(meth);
Py_DECREF(meth);
if (fno == NULL)