mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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).
This commit is contained in:
parent
85c1ba5d74
commit
bae07c9baf
24 changed files with 72 additions and 199 deletions
|
@ -102,13 +102,6 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
|
|||
#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 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue