Commit efee9f5f authored by Neal Norwitz's avatar Neal Norwitz

Use unicode in more places. Fixes a problem with str8 + str in test.

parent ae404e2e
...@@ -87,7 +87,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject ...@@ -87,7 +87,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
} }
if (!isolation_level) { if (!isolation_level) {
isolation_level = PyString_FromString(""); isolation_level = PyUnicode_FromString("");
if (!isolation_level) { if (!isolation_level) {
return -1; return -1;
} }
...@@ -828,24 +828,28 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py ...@@ -828,24 +828,28 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
self->inTransaction = 0; self->inTransaction = 0;
} else { } else {
const char *statement;
Py_ssize_t size;
Py_INCREF(isolation_level); Py_INCREF(isolation_level);
self->isolation_level = isolation_level; self->isolation_level = isolation_level;
begin_statement = PyString_FromString("BEGIN "); begin_statement = PyUnicode_FromString("BEGIN ");
if (!begin_statement) { if (!begin_statement) {
return -1; return -1;
} }
PyString_Concat(&begin_statement, isolation_level); PyUnicode_Concat(begin_statement, isolation_level);
if (!begin_statement) { if (!begin_statement) {
return -1; return -1;
} }
self->begin_statement = PyMem_Malloc(PyString_Size(begin_statement) + 2); statement = PyUnicode_AsStringAndSize(begin_statement, &size);
self->begin_statement = PyMem_Malloc(size + 2);
if (!self->begin_statement) { if (!self->begin_statement) {
return -1; return -1;
} }
strcpy(self->begin_statement, PyString_AsString(begin_statement)); strcpy(self->begin_statement, statement);
Py_DECREF(begin_statement); Py_DECREF(begin_statement);
} }
......
...@@ -359,13 +359,13 @@ PyMODINIT_FUNC init_sqlite3(void) ...@@ -359,13 +359,13 @@ PyMODINIT_FUNC init_sqlite3(void)
Py_DECREF(tmp_obj); Py_DECREF(tmp_obj);
} }
if (!(tmp_obj = PyString_FromString(PYSQLITE_VERSION))) { if (!(tmp_obj = PyUnicode_FromString(PYSQLITE_VERSION))) {
goto error; goto error;
} }
PyDict_SetItemString(dict, "version", tmp_obj); PyDict_SetItemString(dict, "version", tmp_obj);
Py_DECREF(tmp_obj); Py_DECREF(tmp_obj);
if (!(tmp_obj = PyString_FromString(sqlite3_libversion()))) { if (!(tmp_obj = PyUnicode_FromString(sqlite3_libversion()))) {
goto error; goto error;
} }
PyDict_SetItemString(dict, "sqlite_version", tmp_obj); PyDict_SetItemString(dict, "sqlite_version", tmp_obj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment