diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-01 11:01:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-01 11:01:05 (GMT) |
commit | 353053d9ad08fea0e205e6c008b8a4350c0188e6 (patch) | |
tree | 3bd4434c152e934fb260c1c1651c080c3df29a14 /Modules/_csv.c | |
parent | 6922b9e4fce635339cb94c2fdef6bba4e2a99621 (diff) | |
download | cpython-353053d9ad08fea0e205e6c008b8a4350c0188e6.zip cpython-353053d9ad08fea0e205e6c008b8a4350c0188e6.tar.gz cpython-353053d9ad08fea0e205e6c008b8a4350c0188e6.tar.bz2 |
[3.8] bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630) (GH-15635)
Only AttributeError should be silenced.
(cherry picked from commit 41c57b335330ff48af098d47e379e0f9ba09d233)
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r-- | Modules/_csv.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index 014cbb4..46d4143 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"); |