mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +03:00
Pass the async parameter to the connection only if nonzero.
This avoids breaking connection subclasses redefining '__init__' (at least when used sync, which is good for most of the people).
This commit is contained in:
parent
c486136df7
commit
c75ddea895
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user