Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 85502:bfaf3a2907bd
Factor-out the common code for setting a KeyError.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Mon, 02 Sep 2013 15:59:26 -0700 |
| parents | ef889c3d5dc6 |
| children | eeec58c57964 |
comparison
equal
deleted
inserted
replaced
| 85501:5c7697f28ee4 | 85502:bfaf3a2907bd |
|---|---|
| 115 tb = PyException_GetTraceback(value); | 115 tb = PyException_GetTraceback(value); |
| 116 Py_XINCREF(exception); | 116 Py_XINCREF(exception); |
| 117 PyErr_Restore(exception, value, tb); | 117 PyErr_Restore(exception, value, tb); |
| 118 } | 118 } |
| 119 | 119 |
| 120 /* Set a key error with the specified argument, wrapping it in a | |
| 121 * tuple automatically so that tuple keys are not unpacked as the | |
| 122 * exception arguments. */ | |
| 123 void | |
| 124 _PyErr_SetKeyError(PyObject *arg) | |
| 125 { | |
| 126 PyObject *tup; | |
| 127 tup = PyTuple_Pack(1, arg); | |
| 128 if (!tup) | |
| 129 return; /* caller will expect error to be set anyway */ | |
| 130 PyErr_SetObject(PyExc_KeyError, tup); | |
| 131 Py_DECREF(tup); | |
| 132 } | |
| 133 | |
| 120 void | 134 void |
| 121 PyErr_SetNone(PyObject *exception) | 135 PyErr_SetNone(PyObject *exception) |
| 122 { | 136 { |
| 123 PyErr_SetObject(exception, (PyObject *)NULL); | 137 PyErr_SetObject(exception, (PyObject *)NULL); |
| 124 } | 138 } |
