mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
This commit is contained in:
parent
f02ea6225b
commit
41c57b3353
14 changed files with 134 additions and 127 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue