mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-02 23:35:46 +03:00
* psycopg/cursor_type.c (cursor_setup): incref before setting
attributes, to make things GC-safe. * psycopg/cursor_int.c (curs_reset): make clearing of description and casts attributes GC-safe.
This commit is contained in:
parent
bbd101bb7e
commit
26693621ef
|
@ -1,5 +1,11 @@
|
|||
2008-05-28 James Henstridge <james@jamesh.id.au>
|
||||
|
||||
* psycopg/cursor_type.c (cursor_setup): incref before setting
|
||||
attributes, to make things GC-safe.
|
||||
|
||||
* psycopg/cursor_int.c (curs_reset): make clearing of description
|
||||
and casts attributes GC-safe.
|
||||
|
||||
* psycopg/typecast.c (typecast_traverse): implement cyclic GC
|
||||
traversal for typecasters.
|
||||
|
||||
|
|
|
@ -34,15 +34,19 @@
|
|||
void
|
||||
curs_reset(cursorObject *self)
|
||||
{
|
||||
PyObject *tmp;
|
||||
|
||||
/* initialize some variables to default values */
|
||||
self->notuples = 1;
|
||||
self->rowcount = -1;
|
||||
self->row = 0;
|
||||
|
||||
Py_XDECREF(self->description);
|
||||
tmp = self->description;
|
||||
Py_INCREF(Py_None);
|
||||
self->description = Py_None;
|
||||
Py_XDECREF(tmp);
|
||||
|
||||
Py_XDECREF(self->casts);
|
||||
tmp = self->casts;
|
||||
self->casts = NULL;
|
||||
Py_XDECREF(tmp);
|
||||
}
|
||||
|
|
|
@ -1590,8 +1590,8 @@ cursor_setup(cursorObject *self, connectionObject *conn, const char *name)
|
|||
"argument 1 must be subclass of psycopg2._psycopg.connection");
|
||||
return 1;
|
||||
} */
|
||||
Py_INCREF(conn);
|
||||
self->conn = conn;
|
||||
Py_INCREF((PyObject*)self->conn);
|
||||
|
||||
self->closed = 0;
|
||||
self->mark = conn->mark;
|
||||
|
@ -1607,6 +1607,7 @@ cursor_setup(cursorObject *self, connectionObject *conn, const char *name)
|
|||
self->string_types = NULL;
|
||||
self->binary_types = NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
self->description = Py_None;
|
||||
Py_INCREF(Py_None);
|
||||
self->pgstatus = Py_None;
|
||||
|
@ -1614,11 +1615,10 @@ cursor_setup(cursorObject *self, connectionObject *conn, const char *name)
|
|||
self->tuple_factory = Py_None;
|
||||
Py_INCREF(Py_None);
|
||||
self->query = Py_None;
|
||||
Py_INCREF(Py_None);
|
||||
|
||||
/* default tzinfo factory */
|
||||
Py_INCREF(pyPsycopgTzFixedOffsetTimezone);
|
||||
self->tzinfo_factory = pyPsycopgTzFixedOffsetTimezone;
|
||||
Py_INCREF(self->tzinfo_factory);
|
||||
|
||||
Dprintf("cursor_setup: good cursor object at %p, refcnt = "
|
||||
FORMAT_CODE_PY_SSIZE_T,
|
||||
|
|
Loading…
Reference in New Issue
Block a user