summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--psycopg/psycopgmodule.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c
index 8ececea..528c592 100644
--- a/psycopg/psycopgmodule.c
+++ b/psycopg/psycopgmodule.c
@@ -197,7 +197,18 @@ psyco_connect(PyObject *self, PyObject *args, PyObject *keywds)
/* allocate connection, fill with errors and return it */
if (factory == NULL) factory = (PyObject *)&connectionType;
- conn = PyObject_CallFunction(factory, "si", dsn, async);
+ /* Here we are breaking the connection.__init__ interface defined
+ * by psycopg2. So, if not requiring an async conn, avoid passing
+ * the async parameter. */
+ /* TODO: would it be possible to avoid an additional parameter
+ * to the conn constructor? A subclass? (but it would require mixins
+ * to further subclass) Another dsn parameter (but is not really
+ * a connection parameter that can be configured) */
+ if (!async) {
+ conn = PyObject_CallFunction(factory, "s", dsn);
+ } else {
+ conn = PyObject_CallFunction(factory, "si", dsn, async);
+ }
}
goto cleanup;