From dbce2618b1c6dcd76a5ae68ee0bc4464b8faecb3 Mon Sep 17 00:00:00 2001 From: Andrew McNamara Date: Mon, 10 Jan 2005 23:17:35 +0000 Subject: [PATCH] Only set error string when dict lookup found no matching key (was setting it for all failures, potentially masking other exceptions). --- Modules/_csv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Modules/_csv.c b/Modules/_csv.c index 7eb1e2275f9..9f715e41d6b 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -127,9 +127,12 @@ get_dialect_from_registry(PyObject * name_obj) PyObject *dialect_obj; dialect_obj = PyDict_GetItem(dialects, name_obj); - if (dialect_obj == NULL) - return PyErr_Format(error_obj, "unknown dialect"); - Py_INCREF(dialect_obj); + if (dialect_obj == NULL) { + if (!PyErr_Occurred()) + PyErr_Format(error_obj, "unknown dialect"); + } + else + Py_INCREF(dialect_obj); return dialect_obj; }