summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/connection.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2011-09-28 05:41:54 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2011-09-28 05:41:54 (GMT)
commitd63a3b8beb4a0841cb59fb3515347ccaab34b733 (patch)
tree3b4e3cc63151c5a5a910c3550a190aefaea96ad4 /Modules/_sqlite/connection.c
parent48d49497c50e79d14e9df9527d766ca3a0a38be5 (diff)
downloadcpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.zip
cpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.tar.gz
cpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.tar.bz2
Implement PEP 393.
Diffstat (limited to 'Modules/_sqlite/connection.c')
-rw-r--r--Modules/_sqlite/connection.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 3c83c7c..310a27c 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -1436,10 +1436,11 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
PyObject* uppercase_name = 0;
PyObject* name;
PyObject* retval;
- Py_UNICODE* chk;
Py_ssize_t i, len;
char *uppercase_name_str;
int rc;
+ unsigned int kind;
+ void *data;
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
goto finally;
@@ -1454,12 +1455,16 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
goto finally;
}
- len = PyUnicode_GET_SIZE(uppercase_name);
- chk = PyUnicode_AS_UNICODE(uppercase_name);
- for (i=0; i<len; i++, chk++) {
- if ((*chk >= '0' && *chk <= '9')
- || (*chk >= 'A' && *chk <= 'Z')
- || (*chk == '_'))
+ if (PyUnicode_READY(uppercase_name))
+ goto finally;
+ len = PyUnicode_GET_LENGTH(uppercase_name);
+ kind = PyUnicode_KIND(uppercase_name);
+ data = PyUnicode_DATA(uppercase_name);
+ for (i=0; i<len; i++) {
+ Py_UCS4 ch = PyUnicode_READ(kind, data, i);
+ if ((ch >= '0' && ch <= '9')
+ || (ch >= 'A' && ch <= 'Z')
+ || (ch == '_'))
{
continue;
} else {