0

pushed exception setting into the relevant function, removed redundant exceptions

The following functions set exceptions automatically:
PyImport_ImportModule, PyObject_GetAttrString, PyArg_ParseTuple. All
the exception setting functions in c_overviewer should act the same
way and set their own exceptions before returning.

Notably, PyDict_GetItemString does *not* set exceptions, so it is
handled specially in render_mode_find_interface.
This commit is contained in:
Aaron Griffith
2011-11-22 17:32:47 -05:00
parent 4739f4af93
commit bca7867b86
2 changed files with 20 additions and 20 deletions

View File

@@ -106,13 +106,13 @@ render_mode_find_interface(const char *mode) {
/* check for custom modes */
custom = PyDict_GetItemString(custom_render_modes, mode);
if (custom == NULL)
return NULL;
return PyErr_Format(PyExc_RuntimeError, "Failed to find rendermode interface (custom not found)");
custom = PyDict_GetItemString(custom, "parent");
if (custom == NULL)
return NULL;
return PyErr_Format(PyExc_RuntimeError, "Failed to find rendermode interface (parent not found)");
custom_parent = PyString_AsString(custom);
if (custom_parent == NULL)
return NULL;
return NULL; // PyString_AsString sets an exception
return render_mode_find_interface(custom_parent);
}
@@ -124,11 +124,11 @@ RenderMode *render_mode_create(const char *mode, RenderState *state) {
iface = render_mode_find_interface(mode);
if (iface == NULL)
return PyErr_Format(PyExc_RuntimeError, "Failed to find rendermode interface");
return NULL;
options = render_mode_create_options(mode);
if (options == NULL)
return PyErr_Format(PyExc_RuntimeError, "Failed to create rendermode options");
return NULL;
ret = calloc(1, sizeof(RenderMode));
if (ret == NULL) {
@@ -150,13 +150,13 @@ RenderMode *render_mode_create(const char *mode, RenderState *state) {
Py_DECREF(options);
free(ret->mode);
free(ret);
return PyErr_Format(PyExc_RuntimeError, "Failed to start rendermode interface");
return NULL;
}
Py_DECREF(options);
return ret;
}
void render_mode_destroy(RenderMode *self) {
self->iface->finish(self->mode, self->state);
free(self->mode);