The *_CheckExact() family sets no exceptions.

So set a runtime exception if the objects passed mismatch.
This commit is contained in:
Joris Vink 2021-09-22 16:48:21 +02:00
parent af45284641
commit 3e85d36532
1 changed files with 8 additions and 2 deletions

View File

@ -5151,13 +5151,17 @@ pydomain_filemaps(struct pydomain *domain, PyObject *args)
if (!PyArg_ParseTuple(args, "O", &dict))
return (NULL);
if (!PyDict_CheckExact(dict))
if (!PyDict_CheckExact(dict)) {
PyErr_SetString(PyExc_RuntimeError, "filemaps not a dict");
return (NULL);
}
idx = 0;
while (PyDict_Next(dict, &idx, &key, &value)) {
if (!PyUnicode_CheckExact(key) ||
!PyUnicode_CheckExact(value)) {
PyErr_SetString(PyExc_RuntimeError,
"filemap entries not strings");
return (NULL);
}
@ -5318,8 +5322,10 @@ python_route_methods(PyObject *obj, PyObject *kwargs, struct kore_route *rt)
int method;
Py_ssize_t list_len, idx;
if (!PyList_CheckExact(obj))
if (!PyList_CheckExact(obj)) {
PyErr_SetString(PyExc_RuntimeError, "methods not a list");
return (KORE_RESULT_ERROR);
}
rt->methods = 0;
list_len = PyList_Size(obj);