diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-01 09:03:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-01 09:03:39 (GMT) |
commit | 41c57b335330ff48af098d47e379e0f9ba09d233 (patch) | |
tree | 15cdef099182eddb04b2276dc51375b8faf28278 /Objects/fileobject.c | |
parent | f02ea6225bc3b71bd5fe66224d199a6e3e23b14d (diff) | |
download | cpython-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 'Objects/fileobject.c')
-rw-r--r-- | Objects/fileobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 0faf7e7..61c9428 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) |