Only set error string when dict lookup found no matching key (was setting

it for all failures, potentially masking other exceptions).
This commit is contained in:
Andrew McNamara 2005-01-10 23:17:35 +00:00
parent b497c106d5
commit dbce2618b1
1 changed files with 6 additions and 3 deletions

View 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;
}