mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue 8781: On systems a signed 4-byte wchar_t and a 4-byte Py_UNICODE, use memcpy to convert between the two (as already done when wchar_t is unsigned)
This commit is contained in:
parent
16925e8539
commit
8515eaefda
4 changed files with 10 additions and 11 deletions
|
@ -289,15 +289,15 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
|
|||
wchar_t *s, *buf = NULL;
|
||||
size_t n1, n2;
|
||||
PyObject *result = NULL;
|
||||
#ifndef HAVE_USABLE_WCHAR_T
|
||||
#if Py_UNICODE_SIZE != SIZEOF_WCHAR_T
|
||||
Py_ssize_t i;
|
||||
#endif
|
||||
|
||||
if (!PyArg_ParseTuple(args, "u#:strxfrm", &s0, &n0))
|
||||
return NULL;
|
||||
|
||||
#ifdef HAVE_USABLE_WCHAR_T
|
||||
s = s0;
|
||||
#if Py_UNICODE_SIZE == SIZEOF_WCHAR_T
|
||||
s = (wchar_t *) s0;
|
||||
#else
|
||||
s = PyMem_Malloc((n0+1)*sizeof(wchar_t));
|
||||
if (!s)
|
||||
|
@ -326,7 +326,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
|
|||
result = PyUnicode_FromWideChar(buf, n2);
|
||||
exit:
|
||||
if (buf) PyMem_Free(buf);
|
||||
#ifndef HAVE_USABLE_WCHAR_T
|
||||
#if Py_UNICODE_SIZE != SIZEOF_WCHAR_T
|
||||
PyMem_Free(s);
|
||||
#endif
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue