From 5d953184a6fae25bf27e769c90b419d9b2aa1af9 Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Wed, 16 May 2012 20:41:56 +0200 Subject: Issue #14779: Get sizeof(void *) directly rather than relying on sysconfig. --- Lib/test/test_buffer.py | 6 ++---- Modules/_testbuffer.c | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 258c850..b6cb3ac 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -747,10 +747,8 @@ if SHORT_TEST: class TestBufferProtocol(unittest.TestCase): def setUp(self): - self.sizeof_void_p = get_config_var('SIZEOF_VOID_P') \ - if sys.platform != 'darwin' else None - if not self.sizeof_void_p: - self.sizeof_void_p = 8 if sys.maxsize > 2**32 else 4 + # The suboffsets tests need sizeof(void *). + self.sizeof_void_p = get_sizeof_void_p() def verify(self, result, obj=-1, itemsize={1}, fmt=-1, readonly={1}, diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c index cc4aea8..1ff685c 100644 --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -2337,6 +2337,12 @@ out: return ret; } +static PyObject * +get_sizeof_void_p(PyObject *self) +{ + return PyLong_FromSize_t(sizeof(void *)); +} + static char get_ascii_order(PyObject *order) { @@ -2726,6 +2732,7 @@ static PyTypeObject StaticArray_Type = { static struct PyMethodDef _testbuffer_functions[] = { {"slice_indices", slice_indices, METH_VARARGS, NULL}, {"get_pointer", get_pointer, METH_VARARGS, NULL}, + {"get_sizeof_void_p", (PyCFunction)get_sizeof_void_p, METH_NOARGS, NULL}, {"get_contiguous", get_contiguous, METH_VARARGS, NULL}, {"is_contiguous", is_contiguous, METH_VARARGS, NULL}, {"cmp_contig", cmp_contig, METH_VARARGS, NULL}, -- cgit v0.12