Issue 14779: test_buffer fails on OS X universal 64-/32-bit builds (original) (raw)

test_buffer can fail when run on an OS X 64-/32-bit universal build of Python is run in 32-bit mode.

$ /usr/local/bin/python3.3 -m test test_buffer [1/1] test_buffer 1 test OK. $ /usr/local/bin/python3.3-32 -m test -v test_buffer == CPython 3.3.0a3 (v3.3.0a3:0b53b70a40a0, May 1 2012, 11:39:35) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] == Darwin-11.4.0-x86_64-i386-64bit little-endian == /private/var/folders/fm/9wjgctqx61n796zt88qmmnxc0000gn/T/test_python_56263 Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1) [1/1] test_buffer [...] test_memoryview_construction (test.test_buffer.TestBufferProtocol) ... FAIL test_ndarray_format_shape (test.test_buffer.TestBufferProtocol) ... FAIL test_ndarray_format_strides (test.test_buffer.TestBufferProtocol) ... FAIL test_ndarray_getbuf (test.test_buffer.TestBufferProtocol) ... FAIL test_ndarray_multidim (test.test_buffer.TestBufferProtocol) ... FAIL test_ndarray_slice_assign_single (test.test_buffer.TestBufferProtocol) ... FAIL [...]

The test is incorrectly testing a compile-time configuration variable which is not meaningful for universal builds since each architecture can have different values. Further, the platform.architecture fallback test is also unreliable; as noted in the docs for the platform module, sys.maxsize should be used for run-time tests. The attached patch fixes the test for OS X.