Skip to content

Commit 16f7fad

Browse files
committed
FROMLIST python#143432: Skip NaN encoding assertions for MIPS
1 parent df79316 commit 16f7fad

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Lib/test/test_struct.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -942,10 +942,14 @@ def test_half_float(self):
942942
else:
943943
expected = 0x7e
944944

945-
packed = struct.pack('<e', math.nan)
946-
self.assertEqual(packed[1] & 0x7e, expected)
947-
packed = struct.pack('<e', -math.nan)
948-
self.assertEqual(packed[1] & 0x7e, expected)
945+
# Skip NaN encoding checks for MIPS because `math.nan` changes its value
946+
# depending on toolchain settings. See:
947+
# https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html#index-mnan_003d2008
948+
if not platform.machine().startswith('mips'):
949+
packed = struct.pack('<e', math.nan)
950+
self.assertEqual(packed[1] & 0x7e, expected)
951+
packed = struct.pack('<e', -math.nan)
952+
self.assertEqual(packed[1] & 0x7e, expected)
949953

950954
# Checks for round-to-even behavior
951955
format_bits_float__rounding_list = [

0 commit comments

Comments
 (0)