Fix Python host-endianness dependencies (#7773)

* In Python tests, use host-endian-independent dtypes

* Fix host endianness dependence in Python flexbuffers

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Ben Beasley
2023-01-10 13:20:08 -05:00
committed by GitHub
parent b50b6be60a
commit b23493a7d2
3 changed files with 23 additions and 23 deletions

View File

@@ -74,15 +74,15 @@ def int_sizes(value):
def int_bytes(value, byte_width):
return struct.pack({1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value)
return struct.pack('<%s' % {1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value)
def uint_bytes(value, byte_width):
return struct.pack({1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value)
return struct.pack('<%s' % {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value)
def float_bytes(value, byte_width):
return struct.pack({4: 'f', 8: 'd'}[byte_width], value)
return struct.pack('<%s' % {4: 'f', 8: 'd'}[byte_width], value)
def min_value(type_, byte_width):