summaryrefslogtreecommitdiff
path: root/psycopg
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2005-01-29 04:16:25 +0000
committerFederico Di Gregorio <fog@initd.org>2005-01-29 04:16:25 +0000
commitb742c48c6711847ec58a5a6778c372e2ac61df6d (patch)
tree7511a9ed04e4d9508bc2e0f1020cb8afdaf6b0bc /psycopg
parent1141149cd3656b4ad68995894070af4f13c24f32 (diff)
downloadpsycopg2-b742c48c6711847ec58a5a6778c372e2ac61df6d.tar.gz
The Andrea's-bunch-o-fixes.
Diffstat (limited to 'psycopg')
-rw-r--r--psycopg/cursor_type.c19
-rw-r--r--psycopg/pqpath.c2
2 files changed, 13 insertions, 8 deletions
diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c
index de32dde..0c48bbf 100644
--- a/psycopg/cursor_type.c
+++ b/psycopg/cursor_type.c
@@ -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;
}
diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c
index c1bfdb1..54f9c4b 100644
--- a/psycopg/pqpath.c
+++ b/psycopg/pqpath.c
@@ -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);