diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 34c695747443cf47d3f0e9e4e28ac947b0f974d2..8365e048b9a99118f0b4dff932673df93a2ad11f 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -33,6 +33,7 @@ #include "psycopg/green.h" #include "psycopg/notify.h" +#include #include /* String indexes match the ISOLATION_LEVEL_* consts */ diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 1672c999a153ed76f2a4af20f3c72e5b7925c0d0..077654e56a6e3836f0e8ef622fcdce8589038a2b 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -35,6 +35,7 @@ #include "psycopg/green.h" #include "psycopg/xid.h" +#include #include #include #include "psycopg/typecast.h" diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 7ab56cbe6b5400a61253476f7d89f5fc09fd181d..03802d6e6de491a3ea3aa6b409e0b8eabe89f7bd 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -47,6 +47,7 @@ #include "psycopg/libpq_support.h" #include "libpq-fe.h" +#include #ifdef _WIN32 /* select() */ #include diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 5ab6f5fdd156b1add3aa9b698bb5ca2da39495ef..d129e87a000bae5c9f8ff747788f3115b78f0b29 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -57,6 +57,8 @@ #include #include "psycopg/adapter_datetime.h" +#include + HIDDEN PyObject *psycoEncodings = NULL; HIDDEN PyObject *sqlstate_errors = NULL; @@ -999,32 +1001,35 @@ INIT_MODULE(_psycopg)(void) /* initialize types and objects not exposed to the module */ Py_SET_TYPE(&typecastType, &PyType_Type); - if (0 > PyType_Ready(&typecastType)) { goto exit; } + if (0 > PyType_Ready(&typecastType)) { goto error; } Py_SET_TYPE(&chunkType, &PyType_Type); - if (0 > PyType_Ready(&chunkType)) { goto exit; } + if (0 > PyType_Ready(&chunkType)) { goto error; } Py_SET_TYPE(&errorType, &PyType_Type); errorType.tp_base = (PyTypeObject *)PyExc_StandardError; - if (0 > PyType_Ready(&errorType)) { goto exit; } + if (0 > PyType_Ready(&errorType)) { goto error; } - if (!(psyco_null = Bytes_FromString("NULL"))) { goto exit; } + if (!(psyco_null = Bytes_FromString("NULL"))) { goto error; } /* initialize the module */ module = PyModule_Create(&psycopgmodule); - if (!module) { goto exit; } + if (!module) { goto error; } - if (0 > add_module_constants(module)) { goto exit; } - if (0 > add_module_types(module)) { goto exit; } - if (0 > datetime_init()) { goto exit; } - if (0 > encodings_init(module)) { goto exit; } - if (0 > typecast_init(module)) { goto exit; } - if (0 > adapters_init(module)) { goto exit; } - if (0 > basic_errors_init(module)) { goto exit; } - if (0 > sqlstate_errors_init(module)) { goto exit; } + if (0 > add_module_constants(module)) { goto error; } + if (0 > add_module_types(module)) { goto error; } + if (0 > datetime_init()) { goto error; } + if (0 > encodings_init(module)) { goto error; } + if (0 > typecast_init(module)) { goto error; } + if (0 > adapters_init(module)) { goto error; } + if (0 > basic_errors_init(module)) { goto error; } + if (0 > sqlstate_errors_init(module)) { goto error; } Dprintf("psycopgmodule: module initialization complete"); -exit: return module; +error: + if (module) + Py_DECREF(module); + return NULL; } diff --git a/psycopg/replication_connection_type.c b/psycopg/replication_connection_type.c index b8c1d2debd8e45c270c70dbfd882263c17cb09e9..7e51904781f29bd4ba049a229be2a92b0e6c613c 100644 --- a/psycopg/replication_connection_type.c +++ b/psycopg/replication_connection_type.c @@ -129,6 +129,11 @@ replicationConnection_repr(replicationConnectionObject *self) self, self->conn.dsn, self->conn.closed); } +static int +replicationConnectionType_traverse(PyObject *self, visitproc visit, void *arg) +{ + return connectionType.tp_traverse(self, visit, arg); +} /* object calculated member list */ @@ -173,7 +178,7 @@ PyTypeObject replicationConnectionType = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_ITER | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ replicationConnectionType_doc, /*tp_doc*/ - 0, /*tp_traverse*/ + replicationConnectionType_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/replication_cursor_type.c b/psycopg/replication_cursor_type.c index 689a131cf05a5707ddac0fae6078b9d84571fa92..ab3ad3c4e403de61d76dd6c25166a9180b57a6d7 100644 --- a/psycopg/replication_cursor_type.c +++ b/psycopg/replication_cursor_type.c @@ -346,6 +346,11 @@ replicationCursor_repr(replicationCursorObject *self) "", self, self->cur.closed); } +static int +replicationCursorType_traverse(PyObject *self, visitproc visit, void *arg) +{ + return cursorType.tp_traverse(self, visit, arg); +} /* object type */ @@ -374,7 +379,7 @@ PyTypeObject replicationCursorType = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_ITER | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ replicationCursorType_doc, /*tp_doc*/ - 0, /*tp_traverse*/ + replicationCursorType_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/