* Create an exception object and add it to the module */
| 224 | * Create an exception object and add it to the module |
| 225 | */ |
| 226 | static PyObject * |
| 227 | PLy_create_exception(char *name, PyObject *base, PyObject *dict, |
| 228 | const char *modname, PyObject *mod) |
| 229 | { |
| 230 | PyObject *exc; |
| 231 | |
| 232 | exc = PyErr_NewException(name, base, dict); |
| 233 | if (exc == NULL) |
| 234 | PLy_elog(ERROR, NULL); |
| 235 | |
| 236 | /* |
| 237 | * PyModule_AddObject does not add a refcount to the object, for some odd |
| 238 | * reason; we must do that. |
| 239 | */ |
| 240 | Py_INCREF(exc); |
| 241 | PyModule_AddObject(mod, modname, exc); |
| 242 | |
| 243 | /* |
| 244 | * The caller will also store a pointer to the exception object in some |
| 245 | * permanent variable, so add another ref to account for that. This is |
| 246 | * probably excessively paranoid, but let's be sure. |
| 247 | */ |
| 248 | Py_INCREF(exc); |
| 249 | return exc; |
| 250 | } |
| 251 | |
| 252 | /* |
| 253 | * Add all the autogenerated exceptions as subclasses of SPIError |
no outgoing calls
no test coverage detected