diff options
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r-- | Modules/_csv.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index 6c00974..d86f63e 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -132,7 +132,7 @@ get_dialect_from_registry(PyObject * name_obj) { PyObject *dialect_obj; - dialect_obj = PyDict_GetItem(_csvstate_global->dialects, name_obj); + dialect_obj = PyDict_GetItemWithError(_csvstate_global->dialects, name_obj); if (dialect_obj == NULL) { if (!PyErr_Occurred()) PyErr_Format(_csvstate_global->error_obj, "unknown dialect"); @@ -1434,8 +1434,12 @@ csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs) static PyObject * csv_unregister_dialect(PyObject *module, PyObject *name_obj) { - if (PyDict_DelItem(_csvstate_global->dialects, name_obj) < 0) - return PyErr_Format(_csvstate_global->error_obj, "unknown dialect"); + if (PyDict_DelItem(_csvstate_global->dialects, name_obj) < 0) { + if (PyErr_ExceptionMatches(PyExc_KeyError)) { + PyErr_Format(_csvstate_global->error_obj, "unknown dialect"); + } + return NULL; + } Py_RETURN_NONE; } |