diff options
author | Daniel Stutzbach <daniel@stutzbachenterprises.com> | 2010-08-24 21:57:33 (GMT) |
---|---|---|
committer | Daniel Stutzbach <daniel@stutzbachenterprises.com> | 2010-08-24 21:57:33 (GMT) |
commit | 8515eaefda6348a72464805ff8d07041d16ab97d (patch) | |
tree | 90ccc8d24e71d167bf85a7bd2abfaf8dc29f1d8a /Modules | |
parent | 16925e8539a39bf5599514d1be3f3c601bbc7b00 (diff) | |
download | cpython-8515eaefda6348a72464805ff8d07041d16ab97d.zip cpython-8515eaefda6348a72464805ff8d07041d16ab97d.tar.gz cpython-8515eaefda6348a72464805ff8d07041d16ab97d.tar.bz2 |
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)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 2 | ||||
-rw-r--r-- | Modules/_ctypes/cfield.c | 7 | ||||
-rw-r--r-- | Modules/_localemodule.c | 8 |
3 files changed, 8 insertions, 9 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 44b2d11..81d3294 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -658,7 +658,7 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) #ifdef CTYPES_UNICODE if (PyUnicode_Check(obj)) { -#ifdef HAVE_USABLE_WCHAR_T +#if Py_UNICODE_SIZE == SIZEOF_WCHAR_T pa->ffi_type = &ffi_type_pointer; pa->value.p = PyUnicode_AS_UNICODE(obj); Py_INCREF(obj); diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index b83447b..3d7d0bc 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1420,12 +1420,11 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size) return NULL; } else Py_INCREF(value); -#ifdef HAVE_USABLE_WCHAR_T - /* HAVE_USABLE_WCHAR_T means that Py_UNICODE and wchar_t is the same - type. So we can copy directly. Hm, are unicode objects always NUL +#if Py_UNICODE_SIZE == SIZEOF_WCHAR_T + /* We can copy directly. Hm, are unicode objects always NUL terminated in Python, internally? */ - *(wchar_t **)ptr = PyUnicode_AS_UNICODE(value); + *(wchar_t **)ptr = (wchar_t *) PyUnicode_AS_UNICODE(value); return value; #else { diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 88f6add..2394206 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -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; |