summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/cursor.c
diff options
context:
space:
mode:
authorGerhard Häring <gh@ghaering.de>2007-08-10 18:15:11 (GMT)
committerGerhard Häring <gh@ghaering.de>2007-08-10 18:15:11 (GMT)
commit6d21456137836b8acd551cf6a51999ad4ff10a91 (patch)
treea9cdbf533531b1326623f704e6155350dddb0b17 /Modules/_sqlite/cursor.c
parentbd4a63e091ddb38a2d55d9c21eee8656863240ca (diff)
downloadcpython-6d21456137836b8acd551cf6a51999ad4ff10a91.zip
cpython-6d21456137836b8acd551cf6a51999ad4ff10a91.tar.gz
cpython-6d21456137836b8acd551cf6a51999ad4ff10a91.tar.bz2
Make the sqlite tests pass.
Diffstat (limited to 'Modules/_sqlite/cursor.c')
-rw-r--r--Modules/_sqlite/cursor.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 055e544..412e386 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -248,7 +248,7 @@ PyObject* _pysqlite_build_column_name(const char* colname)
if ((*pos == '[') && (pos > colname) && (*(pos-1) == ' ')) {
pos--;
}
- return PyString_FromStringAndSize(colname, pos - colname);
+ return PyUnicode_FromStringAndSize(colname, pos - colname);
}
}
}
@@ -372,8 +372,10 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
}
} else if (self->connection->text_factory == (PyObject*)&PyString_Type) {
converted = PyString_FromString(val_str);
+ } else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) {
+ converted = PyBytes_FromStringAndSize(val_str, strlen(val_str));
} else {
- converted = PyObject_CallFunction(self->connection->text_factory, "s", val_str);
+ converted = PyObject_CallFunction(self->connection->text_factory, "y", val_str);
}
} else {
/* coltype == SQLITE_BLOB */
@@ -746,17 +748,13 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
return NULL;
}
- if (PyString_Check(script_obj)) {
- script_cstr = PyString_AsString(script_obj);
- } else if (PyUnicode_Check(script_obj)) {
- script_str = PyUnicode_AsUTF8String(script_obj);
- if (!script_str) {
+ if (PyUnicode_Check(script_obj)) {
+ script_cstr = PyUnicode_AsString(script_obj);
+ if (!script_cstr) {
return NULL;
}
-
- script_cstr = PyString_AsString(script_str);
} else {
- PyErr_SetString(PyExc_ValueError, "script argument must be unicode or string.");
+ PyErr_SetString(PyExc_ValueError, "script argument must be unicode.");
return NULL;
}