mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
Factor-out the common code for setting a KeyError.
This commit is contained in:
parent
7f5c22c022
commit
69492dab07
4 changed files with 20 additions and 33 deletions
|
@ -117,6 +117,20 @@ PyErr_SetObject(PyObject *exception, PyObject *value)
|
|||
PyErr_Restore(exception, value, tb);
|
||||
}
|
||||
|
||||
/* Set a key error with the specified argument, wrapping it in a
|
||||
* tuple automatically so that tuple keys are not unpacked as the
|
||||
* exception arguments. */
|
||||
void
|
||||
_PyErr_SetKeyError(PyObject *arg)
|
||||
{
|
||||
PyObject *tup;
|
||||
tup = PyTuple_Pack(1, arg);
|
||||
if (!tup)
|
||||
return; /* caller will expect error to be set anyway */
|
||||
PyErr_SetObject(PyExc_KeyError, tup);
|
||||
Py_DECREF(tup);
|
||||
}
|
||||
|
||||
void
|
||||
PyErr_SetNone(PyObject *exception)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue