The Andrea's-bunch-o-fixes.

This commit is contained in:
Federico Di Gregorio 2005-01-29 04:16:25 +00:00
parent 1141149cd3
commit b742c48c67
3 changed files with 26 additions and 8 deletions

View File

@ -1,3 +1,16 @@
2005-01-29 Federico Di Gregorio <fog@debian.org>
* psycopg/pqpath.c (_pq_fetch_tuples): fixed scale-related
segfault (*fourth* mail from Andrea. Another couple like this and
psycopg 2 will exit alpha at warp speed.)
* psycopg/pqpath.c (pq_fetch): _pq_copy_out_3 -> _pq_copy_out_v3
(second and third mail from Andrea. :/)
* psycopg/cursor_type.c (_psyco_curs_has_write_check): added check
on .write() attribute, fixed compilation problems (first mail from
Andrea Arcangeli.)
2005-01-20 Federico Di Gregorio <fog@debian.org>
* lib/extensions.py (register_adapter): added register_adapter

View File

@ -896,12 +896,17 @@ psyco_curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs)
"copy_from(file, table, sep='\\t', null='NULL') -> copy file to table."
static int
_psyco_curs_copy_from_check(PyObject *o)
_psyco_curs_has_write_check(PyObject* o, void* var)
{
if (PyObject_GetAttrString(o, "write")
if (PyObject_HasAttrString(o, "write")) {
Py_INCREF(o);
*((PyObject**)var) = o;
return 1;
else
}
else {
PyErr_SetString(TypeError, "argument 1 must have a .write() method");
return 0;
}
}
static PyObject *
@ -912,9 +917,9 @@ psyco_curs_copy_from(cursorObject *self, PyObject *args)
long int bufsize = DEFAULT_COPYSIZE;
PyObject *file, *res = NULL;
if (!PyArg_ParseTuple(args, "O!s|ssi",
&PyFile_Type, &file, &table_name,
&sep, &null, &bufsize)) {
if (!PyArg_ParseTuple(args, "O&s|ssi",
_psyco_curs_has_write_check, &file,
&table_name, &sep, &null, &bufsize)) {
return NULL;
}

View File

@ -749,7 +749,7 @@ pq_fetch(cursorObject *curs)
curs->rowcount = 0;
#ifdef HAVE_PQPROTOCOL3
if (curs->conn->protocol == 3)
ex = _pq_copy_out_3(curs);
ex = _pq_copy_out_v3(curs);
else
#endif
ex = _pq_copy_out(curs);