Author: guido.van.rossum
Date: Wed Aug 29 05:34:29 2007
New Revision: 57642

Modified:
   python/branches/py3k/Modules/_sqlite/cursor.c
   python/branches/py3k/Modules/_sqlite/statement.c
Log:
"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.


Modified: python/branches/py3k/Modules/_sqlite/cursor.c
==============================================================================
--- python/branches/py3k/Modules/_sqlite/cursor.c       (original)
+++ python/branches/py3k/Modules/_sqlite/cursor.c       Wed Aug 29 05:34:29 2007
@@ -497,8 +497,10 @@
         rc = pysqlite_statement_reset(self->statement);
     }
 
-    if (PyObject_AsCharBuffer(operation, &operation_cstr, &operation_len) < 0)
+    operation_cstr = PyUnicode_AsString(operation);
+    if (operation == NULL)
         goto error;
+    operation_len = strlen(operation_cstr); /* XXX */
 
     /* reset description and rowcount */
     Py_DECREF(self->description);

Modified: python/branches/py3k/Modules/_sqlite/statement.c
==============================================================================
--- python/branches/py3k/Modules/_sqlite/statement.c    (original)
+++ python/branches/py3k/Modules/_sqlite/statement.c    Wed Aug 29 05:34:29 2007
@@ -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,
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to