summaryrefslogtreecommitdiff
path: root/psycopg/adapter_binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'psycopg/adapter_binary.c')
-rw-r--r--psycopg/adapter_binary.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c
index df19388..5938bcf 100644
--- a/psycopg/adapter_binary.c
+++ b/psycopg/adapter_binary.c
@@ -141,7 +141,9 @@ binary_quote(binaryObject *self)
/* if we got a plain string or a buffer we escape it and save the buffer */
if (PyString_Check(self->wrapped) || PyBuffer_Check(self->wrapped)) {
/* escape and build quoted buffer */
- PyObject_AsCharBuffer(self->wrapped, &buffer, &buffer_len);
+ if (PyObject_AsReadBuffer(self->wrapped, (const void **)&buffer,
+ &buffer_len) < 0)
+ return NULL;
to = (char *)binary_escape((unsigned char*)buffer, (size_t) buffer_len,
&len, self->conn ? ((connectionObject*)self->conn)->pgconn : NULL);