Index: src/org/python/core/PySystemState.java =================================================================== --- src/org/python/core/PySystemState.java (Revision 7191) +++ src/org/python/core/PySystemState.java (Arbeitskopie) @@ -13,6 +13,7 @@ import java.lang.reflect.Method; import java.net.URL; import java.net.URLDecoder; +import java.nio.ByteOrder; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; import java.security.AccessControlException; @@ -105,7 +106,7 @@ public static PyObject prefix; public static PyObject exec_prefix = Py.EmptyString; - public static final PyString byteorder = new PyString("big"); + public static final PyString byteorder = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN ? new PyString("big") : new PyString("little"); public static final int maxint = Integer.MAX_VALUE; public static final int minint = Integer.MIN_VALUE; Index: src/org/python/modules/struct.java =================================================================== --- src/org/python/modules/struct.java (Revision 7191) +++ src/org/python/modules/struct.java (Arbeitskopie) @@ -19,6 +19,7 @@ import org.python.core.PyTuple; import java.math.BigInteger; +import java.nio.ByteOrder; import org.python.core.PyArray; /** @@ -859,27 +860,6 @@ new BEDoubleFormatDef() .init('d', 8, 0), }; - private static FormatDef[] native_table = { - new PadFormatDef() .init('x', 1, 0), - new ByteFormatDef() .init('b', 1, 0), - new UnsignedByteFormatDef() .init('B', 1, 0), - new CharFormatDef() .init('c', 1, 0), - new StringFormatDef() .init('s', 1, 0), - new PascalStringFormatDef() .init('p', 1, 0), - new BEShortFormatDef() .init('h', 2, 2), - new BEUnsignedShortFormatDef() .init('H', 2, 2), - new BEIntFormatDef() .init('i', 4, 4), - new BEUnsignedIntFormatDef() .init('I', 4, 4), - new BEIntFormatDef() .init('l', 4, 4), - new BEUnsignedIntFormatDef() .init('L', 4, 4), - new BELongFormatDef() .init('q', 8, 8), - new BEUnsignedLongFormatDef() .init('Q', 8, 8), - new BEFloatFormatDef() .init('f', 4, 4), - new BEDoubleFormatDef() .init('d', 8, 8), - }; - - - static FormatDef[] whichtable(String pfmt) { char c = pfmt.charAt(0); switch (c) { @@ -893,7 +873,11 @@ return bigendian_table; case '@': default: - return native_table; + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { + return bigendian_table; + } else { + return lilendian_table; + } } }