mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
This commit is contained in:
parent
a180b007d9
commit
a24107b04c
31 changed files with 538 additions and 242 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue