Fix for endianness test on Python

This is another partial fix for #1849, and a follow-on to #1855.