Skip to content

Commit 8ff4af9

Browse files
committed
Skip NaN encoding assertions for MIPS
1 parent 68fcb95 commit 8ff4af9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_struct.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -942,10 +942,15 @@ 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://en.wikipedia.org/wiki/NaN#Encoding
948+
# https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/MIPS-Options.html#index-mnan_003d2008
949+
if not platform.machines().startswith('mips'):
950+
packed = struct.pack('<e', math.nan)
951+
self.assertEqual(packed[1] & 0x7e, expected)
952+
packed = struct.pack('<e', -math.nan)
953+
self.assertEqual(packed[1] & 0x7e, expected)
949954

950955
# Checks for round-to-even behavior
951956
format_bits_float__rounding_list = [

0 commit comments

Comments
 (0)