1 This patch fixes limitation in python which expects strxfrm function to return
2 string with characters with values lower than 10ffff. This is know issue:
4 https://bugs.python.org/issue16258
6 This is not for upstream as the idea is from the bug itself and was rejected
7 for use on all platforms.
9 --- Python-3.9.1/Modules/_localemodule.c
10 +++ Python-3.9.1/Modules/_localemodule.c
11 @@ -363,9 +363,10 @@ Return a string that can be used as a ke
13 PyLocale_strxfrm(PyObject* self, PyObject* args)
18 - wchar_t *s = NULL, *buf = NULL;
19 + wchar_t *s = NULL, *buf = NULL, *solbuf = NULL;
21 PyObject *result = NULL;
23 @@ -409,8 +410,23 @@ PyLocale_strxfrm(PyObject* self, PyObjec
27 - result = PyUnicode_FromWideChar(buf, n2);
29 + /* Split each character in resulting wide string in two
30 + parts in order to prevent Python ValueErrors on Solaris. */
31 + solbuf = PyMem_New(wchar_t, (n2*2) + 1);
36 + for (i = 0, j = 0; i < n2; i ++, j+= 2) {
37 + solbuf[j] = 0x10000 + (buf[i] >> 16);
38 + solbuf[j+1] = buf[i] & 0xffff;
42 + result = PyUnicode_FromWideChar(solbuf, n2*2);