"Martin v. L?wis" <mar...@v.loewis.de> wrote: [http://bugs.python.org/issue14779] >> - self.sizeof_void_p = get_config_var('SIZEOF_VOID_P') >> + 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 architecture()[0] == '64bit' else 4 >> + self.sizeof_void_p = 8 if sys.maxsize> 2**32 else 4 >> > > Why not unconditionally use sys.maxsize?
Because the tests need sizeof(void *). In an array with suboffsets void pointers are embedded at the start of the array. The C standard doesn't guarantee sizeof(void *) == sizeof(size_t). In fact, there are machines where sizeof(void *) > sizeof(size_t): http://comments.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/651 http://www-01.ibm.com/support/docview.wss?uid=swg27019425 If you change pyconfig.h to 128 bit pointers while leaving sizeof(size_t) and sizeof(ssize_t) at 8, pyport.h by itself doesn't catch the mismatch. /* The size of `uintptr_t', as computed by sizeof. */ #define SIZEOF_UINTPTR_T 16 /* The size of `void *', as computed by sizeof. */ #define SIZEOF_VOID_P 16 However, now that I tried to compile Python with that pyconfig.h, longobject.c *does* catch it: Objects/longobject.c:943:5: error: #error "PyLong_FromVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" Objects/longobject.c:970:5: error: #error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" If sizeof(void *) == sizeof(size_t) is the general assumption for compiling Python, I think the test should happen prominently in either pyport.h or Python.h. > I'd also hard-code that sys.maxsize ought to be either 2**31-1 or 2**63-1. I would have done exactly that, but the example in the docs that was quoted to me in the issue uses > 2**32: http://docs.python.org/dev/library/platform.html Stefan Krah _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com