]> granicus.if.org Git - python/commitdiff
Only set error string when dict lookup found no matching key (was setting
authorAndrew McNamara <andrewm@object-craft.com.au>
Mon, 10 Jan 2005 23:17:35 +0000 (23:17 +0000)
committerAndrew McNamara <andrewm@object-craft.com.au>
Mon, 10 Jan 2005 23:17:35 +0000 (23:17 +0000)
it for all failures, potentially masking other exceptions).

Modules/_csv.c

index 7eb1e2275f9a27fd1e7c4c1580de4f07a28d1685..9f715e41d6b3b4516052aa73c787e68236bc795d 100644 (file)
@@ -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;
 }