diff Modules/_sqlite/statement.c @ 43487:8c10aac37037

Breaking ground for PEP 3137 implementation: Get rid of buffer(). Use memoryview() in its place where possible. In a few places, do things a bit different, because memoryview() can't slice (yet).
author Guido van Rossum <guido@python.org>
date Mon, 08 Oct 2007 02:46:15 +0000
parents 3a56e73ae919
children 003d35215ef2
line wrap: on
line diff
--- a/Modules/_sqlite/statement.c	Sun Oct 07 23:12:41 2007 +0000
+++ b/Modules/_sqlite/statement.c	Mon Oct 08 02:46:15 2007 +0000
@@ -102,13 +102,6 @@
 #endif
     } else if (PyFloat_Check(parameter)) {
         rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
-    } else if (PyBuffer_Check(parameter)) {
-        if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {
-            rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT);
-        } else {
-            PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
-            rc = -1;
-        }
     } else if PyString_Check(parameter) {
         string = PyString_AsString(parameter);
         rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
@@ -118,6 +111,13 @@
 
         rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
         Py_DECREF(stringval);
+    } else if (PyObject_CheckBuffer(parameter)) {
+        if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {
+            rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT);
+        } else {
+            PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
+            rc = -1;
+        }
     } else {
         rc = -1;
     }