From 408c76fdb67dc80fea108a6484e8c49e87df74c4 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 6 Apr 2013 01:34:12 +0100 Subject: [PATCH] Fixed build on windows Will fail with error: initializer element is not constant --- psycopg/psycopgmodule.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 46f27dae..206a7883 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -409,8 +409,8 @@ static struct { PyObject **base; const char *docstr; } exctable[] = { - { "psycopg2.Error", &Error, &PyExc_StandardError, Error_doc }, - { "psycopg2.Warning", &Warning, &PyExc_StandardError, Warning_doc }, + { "psycopg2.Error", &Error, NULL, Error_doc }, + { "psycopg2.Warning", &Warning, NULL, Warning_doc }, { "psycopg2.InterfaceError", &InterfaceError, &Error, InterfaceError_doc }, { "psycopg2.DatabaseError", &DatabaseError, &Error, DatabaseError_doc }, { "psycopg2.InternalError", &InternalError, &DatabaseError, InternalError_doc }, @@ -458,8 +458,12 @@ psyco_errors_init(void) Py_CLEAR(str); } + /* can't put PyExc_StandardError in the static exctable: + * windows build will fail */ 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; } Py_CLEAR(dict);