diff --git a/doc/source/reference/c-api.config.rst b/doc/source/reference/c-api.config.rst index 0989c53d7ee7..9978434fcd81 100644 --- a/doc/source/reference/c-api.config.rst +++ b/doc/source/reference/c-api.config.rst @@ -34,10 +34,10 @@ information is available to the pre-processor. sizeof(long) -.. cvar:: NPY_SIZEOF_LONG_LONG +.. cvar:: NPY_SIZEOF_LONGLONG sizeof(longlong) where longlong is defined appropriately on the - platform (A macro defines **NPY_SIZEOF_LONGLONG** as well.) + platform. .. cvar:: NPY_SIZEOF_PY_LONG_LONG diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c index 530edbb1ac23..35156e72a65d 100644 --- a/numpy/core/src/multiarray/buffer.c +++ b/numpy/core/src/multiarray/buffer.c @@ -299,11 +299,11 @@ _buffer_format_string(PyArray_Descr *descr, _tmp_string_t *str, int is_standard_size = 1; int is_native_only_type = (descr->type_num == NPY_LONGDOUBLE || descr->type_num == NPY_CLONGDOUBLE); -#if NPY_SIZEOF_LONG_LONG != 8 - is_native_only_type = is_native_only_type || ( - descr->type_num == NPY_LONGLONG || - descr->type_num == NPY_ULONGLONG); -#endif + if (sizeof(npy_longlong) != 8) { + is_native_only_type = is_native_only_type || ( + descr->type_num == NPY_LONGLONG || + descr->type_num == NPY_ULONGLONG); + } *offset += descr->elsize; @@ -339,6 +339,7 @@ _buffer_format_string(PyArray_Descr *descr, _tmp_string_t *str, "cannot expose native-only dtype '%c' in " "non-native byte order '%c' via buffer interface", descr->type, descr->byteorder); + return -1; } } diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 6697b8131ed9..5fb53fbb1505 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -2650,17 +2650,21 @@ def test_roundtrip(self): x = np.array([1,2,3], dtype='