Skip to content

Commit 349c3b2

Browse files
Ensure that it works for signed wchar_t.
1 parent 9aa3c9d commit 349c3b2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Modules/_localemodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ _locale_strxfrm_impl(PyObject *module, PyObject *str)
501501
*/
502502
size_t n3 = 0;
503503
for (size_t i = 0; i < n2; i++) {
504-
if (buf[i] > 0x10000) {
504+
if ((Py_UCS4)buf[i] > 0x10000u) {
505505
n3++;
506506
}
507507
}
@@ -514,10 +514,10 @@ _locale_strxfrm_impl(PyObject *module, PyObject *str)
514514
}
515515
size_t j = 0;
516516
for (size_t i = 0; i < n2; i++) {
517-
wchar_t c = buf[i];
518-
if (c > 0x10000) {
519-
buf2[j++] = (((Py_UCS4)c) >> 16) | 0x10000u;
520-
buf2[j++] = ((Py_UCS4)c) & 0xffffu;
517+
Py_UCS4 c = (Py_UCS4)buf[i];
518+
if (c > 0x10000u) {
519+
buf2[j++] = (c >> 16) | 0x10000u;
520+
buf2[j++] = c & 0xFFFFu;
521521
}
522522
else {
523523
buf2[j++] = c;

0 commit comments

Comments
 (0)