diff options
-rw-r--r-- | c/test_c.py | 5 | ||||
-rw-r--r-- | cffi/_cffi_include.h | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/c/test_c.py b/c/test_c.py index 8138b53..f95a1e9 100644 --- a/c/test_c.py +++ b/c/test_c.py @@ -2110,7 +2110,10 @@ def test_wchar(): if sys.platform.startswith("linux"): BWChar = new_primitive_type("wchar_t") assert sizeof(BWChar) == 4 - assert int(cast(BWChar, -1)) == -1 # signed, on linux + if platform.machine().startswith(('arm', 'aarch64')): + assert int(cast(BWChar, -1)) == 4294967295 # unsigned, on ARM + else: + assert int(cast(BWChar, -1)) == -1 # "often" signed... def test_char16(): BChar16 = new_primitive_type("char16_t") diff --git a/cffi/_cffi_include.h b/cffi/_cffi_include.h index 6d4cccc..4f8ef82 100644 --- a/cffi/_cffi_include.h +++ b/cffi/_cffi_include.h @@ -238,9 +238,9 @@ _CFFI_UNUSED_FN static uint16_t _cffi_to_c_char16_t(PyObject *o) _CFFI_UNUSED_FN static PyObject *_cffi_from_c_char16_t(uint16_t x) { if (sizeof(_cffi_wchar_t) == 2) - return _cffi_from_c_wchar_t(x); + return _cffi_from_c_wchar_t((_cffi_wchar_t)x); else - return _cffi_from_c_wchar3216_t(x); + return _cffi_from_c_wchar3216_t((int)x); } _CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o) @@ -254,7 +254,7 @@ _CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o) _CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(int x) { if (sizeof(_cffi_wchar_t) == 4) - return _cffi_from_c_wchar_t(x); + return _cffi_from_c_wchar_t((_cffi_wchar_t)x); else return _cffi_from_c_wchar3216_t(x); } |