Fixed build on windows

Will fail with error: initializer element is not constant
This commit is contained in:
Daniele Varrazzo 2013-04-06 01:34:12 +01:00
parent d36024dc1f
commit 408c76fdb6

View File

@ -409,8 +409,8 @@ static struct {
PyObject **base; PyObject **base;
const char *docstr; const char *docstr;
} exctable[] = { } exctable[] = {
{ "psycopg2.Error", &Error, &PyExc_StandardError, Error_doc }, { "psycopg2.Error", &Error, NULL, Error_doc },
{ "psycopg2.Warning", &Warning, &PyExc_StandardError, Warning_doc }, { "psycopg2.Warning", &Warning, NULL, Warning_doc },
{ "psycopg2.InterfaceError", &InterfaceError, &Error, InterfaceError_doc }, { "psycopg2.InterfaceError", &InterfaceError, &Error, InterfaceError_doc },
{ "psycopg2.DatabaseError", &DatabaseError, &Error, DatabaseError_doc }, { "psycopg2.DatabaseError", &DatabaseError, &Error, DatabaseError_doc },
{ "psycopg2.InternalError", &InternalError, &DatabaseError, InternalError_doc }, { "psycopg2.InternalError", &InternalError, &DatabaseError, InternalError_doc },
@ -458,8 +458,12 @@ psyco_errors_init(void)
Py_CLEAR(str); Py_CLEAR(str);
} }
/* can't put PyExc_StandardError in the static exctable:
* windows build will fail */
if (!(*exctable[i].exc = PyErr_NewException( if (!(*exctable[i].exc = PyErr_NewException(
exctable[i].name, *exctable[i].base, dict))) { exctable[i].name,
exctable[i].base ? *exctable[i].base : PyExc_StandardError,
dict))) {
goto exit; goto exit;
} }
Py_CLEAR(dict); Py_CLEAR(dict);