Mercurial > cpython-lru_cache-weakref
diff Modules/_sqlite/statement.c @ 42970:cb5ae020a060
"Fix" a few places that were using PyObject_AsCharBuffer() to convert a string
(PyUnicode these days) to a char* + length. The fix consists of calling
PyUnicode_AsString() and strlen(). This is not ideal, but AsCharBuffer()
is definitely not the API to use.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 29 Aug 2007 03:34:29 +0000 |
| parents | e64286053b25 |
| children | 3a56e73ae919 |
line wrap: on
line diff
--- a/Modules/_sqlite/statement.c Wed Aug 29 03:22:59 2007 +0000 +++ b/Modules/_sqlite/statement.c Wed Aug 29 03:34:29 2007 +0000 @@ -50,10 +50,12 @@ self->st = NULL; self->in_use = 0; - if (PyObject_AsCharBuffer(sql, &sql_cstr, &sql_cstr_len) < 0) { + sql_cstr = PyUnicode_AsString(sql); + if (sql_cstr == NULL) { rc = PYSQLITE_SQL_WRONG_TYPE; return rc; } + sql_cstr_len = strlen(sql_cstr); /* XXX */ self->in_weakreflist = NULL; Py_INCREF(sql); @@ -214,10 +216,12 @@ Py_ssize_t sql_len; sqlite3_stmt* new_st; - if (PyObject_AsCharBuffer(self->sql, &sql_cstr, &sql_len) < 0) { + sql_cstr = PyUnicode_AsString(self->sql); + if (sql_cstr == NULL) { rc = PYSQLITE_SQL_WRONG_TYPE; return rc; } + sql_len = strlen(sql_cstr); /* XXXX */ rc = sqlite3_prepare(self->db, sql_cstr,
