summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/statement.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-29 13:53:23 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-29 13:53:23 (GMT)
commit7d1df6c9b1a7e075c03c4790f47bc83e0104579f (patch)
tree6dceba59593ca682c88dd1a699fec2fc51f78129 /Modules/_sqlite/statement.c
parent9befa93b04ee0c485615d87e4b34dcfe5e811194 (diff)
downloadcpython-7d1df6c9b1a7e075c03c4790f47bc83e0104579f.zip
cpython-7d1df6c9b1a7e075c03c4790f47bc83e0104579f.tar.gz
cpython-7d1df6c9b1a7e075c03c4790f47bc83e0104579f.tar.bz2
Add PyUnicode_AsStringAndSize(), which is like PyUnicode_AsString() but
has an extra (optional) output parameter through which it returns the size. Use this in a few places where I used PyUnicode_AsString() + strlen(), and in one new place (which fixes test_pep263).
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r--Modules/_sqlite/statement.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index a5801d6..b1a4e76 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -50,12 +50,11 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
self->st = NULL;
self->in_use = 0;
- sql_cstr = PyUnicode_AsString(sql);
+ sql_cstr = PyUnicode_AsStringAndSize(sql, &sql_cstr_len);
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);
@@ -216,12 +215,11 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
Py_ssize_t sql_len;
sqlite3_stmt* new_st;
- sql_cstr = PyUnicode_AsString(self->sql);
+ sql_cstr = PyUnicode_AsStringAndSize(self->sql, &sql_len);
if (sql_cstr == NULL) {
rc = PYSQLITE_SQL_WRONG_TYPE;
return rc;
}
- sql_len = strlen(sql_cstr); /* XXXX */
rc = sqlite3_prepare(self->db,
sql_cstr,