Skip to content

Commit 07a3170

Browse files
committed
use proper unicode string access idiom in _sqlite/row.c
1 parent e870f47 commit 07a3170

File tree

1 file changed

+13
-4
lines changed
  • graalpython/com.oracle.graal.python.cext/modules/_sqlite

1 file changed

+13
-4
lines changed

graalpython/com.oracle.graal.python.cext/modules/_sqlite/row.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,19 @@ equal_ignore_case(PyObject *left, PyObject *right)
111111
if (PyUnicode_GET_LENGTH(right) != len) {
112112
return 0;
113113
}
114-
const Py_UCS1 *p1 = PyUnicode_1BYTE_DATA(left);
115-
const Py_UCS1 *p2 = PyUnicode_1BYTE_DATA(right);
116-
for (; len; len--, p1++, p2++) {
117-
if (Py_TOLOWER(*p1) != Py_TOLOWER(*p2)) {
114+
115+
/*
116+
* Modified in GraalPy:
117+
* PyUnicode_IS_ASCII does not imply PyUnicode_1BYTE_KIND, so use the
118+
* proper PyUnicode_READ idiom for iterating the strings.
119+
*/
120+
int left_kind = PyUnicode_KIND(left);
121+
int right_kind = PyUnicode_KIND(right);
122+
void* left_data = PyUnicode_DATA(left);
123+
void* right_data = PyUnicode_DATA(right);
124+
125+
for (int i = 0; i < len; i++) {
126+
if (Py_TOLOWER(PyUnicode_READ(left_kind, left_data, i)) != Py_TOLOWER(PyUnicode_READ(right_kind, right_data, i))) {
118127
return 0;
119128
}
120129
}

0 commit comments

Comments
 (0)