Skip to content

Commit 92c7731

Browse files
author
andrewmcnamara
committed
Only set error string when dict lookup found no matching key (was setting
it for all failures, potentially masking other exceptions). git-svn-id: http://svn.python.org/projects/python/trunk@38261 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent a4c4d76 commit 92c7731

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Modules/_csv.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ get_dialect_from_registry(PyObject * name_obj)
127127
PyObject *dialect_obj;
128128

129129
dialect_obj = PyDict_GetItem(dialects, name_obj);
130-
if (dialect_obj == NULL)
131-
return PyErr_Format(error_obj, "unknown dialect");
132-
Py_INCREF(dialect_obj);
130+
if (dialect_obj == NULL) {
131+
if (!PyErr_Occurred())
132+
PyErr_Format(error_obj, "unknown dialect");
133+
}
134+
else
135+
Py_INCREF(dialect_obj);
133136
return dialect_obj;
134137
}
135138

0 commit comments

Comments
 (0)