Skip to content

Commit 96815eb

Browse files
committed
Fix SNaN broken tests on HP PA RISC
While looking at python#140028 I found some unrelated test regressions in the 3.14 cycle. These seem to all come from python#130317. From what I can tell, that made Python more correct than it was before. According to [0] HP PA RISC uses 1 for SNaN and thus a 0 for QNaN. Update tests to expect this. [0]: https://grouper.ieee.org/groups/1788/email/msg03272.html
1 parent 237dca5 commit 96815eb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Lib/test/test_capi/test_float.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import math
22
import random
3+
import platform
34
import sys
45
import unittest
56
import warnings
@@ -197,6 +198,9 @@ def test_pack_unpack_roundtrip_for_nans(self):
197198
# PyFloat_Pack/Unpack*() API. See also gh-130317 and
198199
# e.g. https://developercommunity.visualstudio.com/t/155064
199200
signaling = 0
201+
if platform.machine().startswith('parisc'):
202+
# HP PA RISC uses 0 for quiet
203+
signaling = 1
200204
quiet = int(not signaling)
201205
if size == 8:
202206
payload = random.randint(signaling, 0x7ffffffffffff)

Lib/test/test_struct.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import math
66
import operator
77
import unittest
8+
import platform
89
import struct
910
import sys
1011
import weakref
@@ -917,10 +918,16 @@ def test_half_float(self):
917918

918919
# Check that packing produces a bit pattern representing a quiet NaN:
919920
# all exponent bits and the msb of the fraction should all be 1.
921+
if platform.machine().startswith('parisc'):
922+
# HP PA RISC uses 0 for quiet
923+
expected = 0x7c
924+
else:
925+
expected = 0x7e
926+
920927
packed = struct.pack('<e', math.nan)
921-
self.assertEqual(packed[1] & 0x7e, 0x7e)
928+
self.assertEqual(packed[1] & 0x7e, expected)
922929
packed = struct.pack('<e', -math.nan)
923-
self.assertEqual(packed[1] & 0x7e, 0x7e)
930+
self.assertEqual(packed[1] & 0x7e, expected)
924931

925932
# Checks for round-to-even behavior
926933
format_bits_float__rounding_list = [

0 commit comments

Comments
 (0)