mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-14 15:02:17 +03:00
Fixed explicit connection.cursor(cursor_factory=None)
Fixes issue #210.
This commit is contained in:
parent
e1eb7a71b0
commit
a1344f30f3
2
NEWS
2
NEWS
|
@ -26,6 +26,8 @@ What's new in psycopg 2.4.7
|
|||
happens for TCP connections instead (:ticket:`#196`).
|
||||
- Fixed overflow opening a lobject with an oid not fitting in a signed int
|
||||
(:ticket:`#203`).
|
||||
- Fixed handling of explicit default ``cursor_factory=None`` in
|
||||
`connection.cursor()` (:ticket:`#210`).
|
||||
- Mark the connection closed if found broken on `poll()`.
|
||||
- Fixed possible segfault in named cursors creation.
|
||||
- Fixed debug build on Windows, thanks to James Emerton.
|
||||
|
|
|
@ -54,7 +54,7 @@ psyco_conn_cursor(connectionObject *self, PyObject *args, PyObject *kwargs)
|
|||
{
|
||||
PyObject *obj;
|
||||
PyObject *name = Py_None;
|
||||
PyObject *factory = (PyObject *)&cursorType;
|
||||
PyObject *factory = Py_None;
|
||||
PyObject *withhold = Py_False;
|
||||
|
||||
static char *kwlist[] = {"name", "cursor_factory", "withhold", NULL};
|
||||
|
@ -72,6 +72,10 @@ psyco_conn_cursor(connectionObject *self, PyObject *args, PyObject *kwargs)
|
|||
|
||||
EXC_IF_CONN_CLOSED(self);
|
||||
|
||||
if (factory == Py_None) {
|
||||
factory = (PyObject *)&cursorType;
|
||||
}
|
||||
|
||||
if (self->status != CONN_STATUS_READY &&
|
||||
self->status != CONN_STATUS_BEGIN &&
|
||||
self->status != CONN_STATUS_PREPARED) {
|
||||
|
|
|
@ -218,6 +218,13 @@ class ConnectionTests(unittest.TestCase):
|
|||
|
||||
self.assert_(not notices, "%d notices raised" % len(notices))
|
||||
|
||||
def test_cursor_factory_none(self):
|
||||
# issue #210
|
||||
conn = psycopg2.connect(dsn)
|
||||
cur = conn.cursor(cursor_factory=None)
|
||||
self.assertEqual(type(cur), psycopg2.extensions.cursor)
|
||||
conn.close()
|
||||
|
||||
def test_failed_init_status(self):
|
||||
class SubConnection(psycopg2.extensions.connection):
|
||||
def __init__(self, dsn):
|
||||
|
|
Loading…
Reference in New Issue
Block a user