summaryrefslogtreecommitdiffstats
path: root/Modules/_csv.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/_csv.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/_csv.c')
-rw-r--r--Modules/_csv.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 9653ff9..aaf3776 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -1382,7 +1382,10 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
Py_DECREF(self);
return NULL;
}
- self->write = _PyObject_GetAttrId(output_file, &PyId_write);
+ if (_PyObject_LookupAttrId(output_file, &PyId_write, &self->write) < 0) {
+ Py_DECREF(self);
+ return NULL;
+ }
if (self->write == NULL || !PyCallable_Check(self->write)) {
PyErr_SetString(PyExc_TypeError,
"argument 1 must have a \"write\" method");