mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 10:23:43 +03:00
Dropped psyco_errors_fill()
Just use psyco_errors_init() for complete errors initialization
This commit is contained in:
parent
1839806c3c
commit
111a71ccee
|
@ -657,7 +657,7 @@ static struct {
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
psyco_errors_init(void)
|
psyco_errors_init(PyObject *module)
|
||||||
{
|
{
|
||||||
/* the names of the exceptions here reflect the organization of the
|
/* the names of the exceptions here reflect the organization of the
|
||||||
psycopg2 module and not the fact the the original error objects
|
psycopg2 module and not the fact the the original error objects
|
||||||
|
@ -678,7 +678,7 @@ psyco_errors_init(void)
|
||||||
|
|
||||||
if (exctable[i].docstr) {
|
if (exctable[i].docstr) {
|
||||||
if (!(str = Text_FromUTF8(exctable[i].docstr))) { goto exit; }
|
if (!(str = Text_FromUTF8(exctable[i].docstr))) { goto exit; }
|
||||||
if (0 != PyDict_SetItemString(dict, "__doc__", str)) { goto exit; }
|
if (0 > PyDict_SetItemString(dict, "__doc__", str)) { goto exit; }
|
||||||
Py_CLEAR(str);
|
Py_CLEAR(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,6 +693,20 @@ psyco_errors_init(void)
|
||||||
Py_CLEAR(dict);
|
Py_CLEAR(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; exctable[i].name; i++) {
|
||||||
|
char *name;
|
||||||
|
if (NULL == exctable[i].exc) { continue; }
|
||||||
|
|
||||||
|
/* the name is the part after the last dot */
|
||||||
|
name = strrchr(exctable[i].name, '.');
|
||||||
|
name = name ? name + 1 : exctable[i].name;
|
||||||
|
|
||||||
|
Py_INCREF(*exctable[i].exc);
|
||||||
|
if (0 > PyModule_AddObject(module, name, *exctable[i].exc)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
@ -701,22 +715,6 @@ exit:
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
psyco_errors_fill(PyObject *dict)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
for (i = 0; exctable[i].name; i++) {
|
|
||||||
if (NULL == exctable[i].exc) { continue; }
|
|
||||||
|
|
||||||
/* the name is the part after the last dot */
|
|
||||||
name = strrchr(exctable[i].name, '.');
|
|
||||||
name = name ? name + 1 : exctable[i].name;
|
|
||||||
|
|
||||||
PyDict_SetItemString(dict, name, *exctable[i].exc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RAISES_NEG
|
RAISES_NEG
|
||||||
static int
|
static int
|
||||||
|
@ -983,8 +981,7 @@ INIT_MODULE(_psycopg)(void)
|
||||||
if (0 != psyco_adapters_init(dict)) { goto exit; }
|
if (0 != psyco_adapters_init(dict)) { goto exit; }
|
||||||
|
|
||||||
/* create a standard set of exceptions and add them to the module's dict */
|
/* create a standard set of exceptions and add them to the module's dict */
|
||||||
if (0 != psyco_errors_init()) { goto exit; }
|
if (0 != psyco_errors_init(module)) { goto exit; }
|
||||||
psyco_errors_fill(dict);
|
|
||||||
|
|
||||||
Dprintf("psycopgmodule: module initialization complete");
|
Dprintf("psycopgmodule: module initialization complete");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user