From 96815eb4227195573728df4515b00d4b77c7d6a3 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Oct 2025 12:56:31 +0200 Subject: [PATCH 1/3] Fix SNaN broken tests on HP PA RISC While looking at #140028 I found some unrelated test regressions in the 3.14 cycle. These seem to all come from #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 --- Lib/test/test_capi/test_float.py | 4 ++++ Lib/test/test_struct.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_capi/test_float.py b/Lib/test/test_capi/test_float.py index f7efe0d02549a3..d71ca1f0c28266 100644 --- a/Lib/test/test_capi/test_float.py +++ b/Lib/test/test_capi/test_float.py @@ -1,5 +1,6 @@ import math import random +import platform import sys import unittest import warnings @@ -197,6 +198,9 @@ def test_pack_unpack_roundtrip_for_nans(self): # PyFloat_Pack/Unpack*() API. See also gh-130317 and # e.g. https://developercommunity.visualstudio.com/t/155064 signaling = 0 + if platform.machine().startswith('parisc'): + # HP PA RISC uses 0 for quiet + signaling = 1 quiet = int(not signaling) if size == 8: payload = random.randint(signaling, 0x7ffffffffffff) diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 7df01f28f09118..bac4bcbe04dcd0 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -5,6 +5,7 @@ import math import operator import unittest +import platform import struct import sys import weakref @@ -917,10 +918,16 @@ def test_half_float(self): # Check that packing produces a bit pattern representing a quiet NaN: # all exponent bits and the msb of the fraction should all be 1. + if platform.machine().startswith('parisc'): + # HP PA RISC uses 0 for quiet + expected = 0x7c + else: + expected = 0x7e + packed = struct.pack(' Date: Wed, 22 Oct 2025 13:59:40 +0200 Subject: [PATCH 2/3] Link to wikipedia --- Lib/test/test_capi/test_float.py | 1 + Lib/test/test_struct.py | 1 + 2 files changed, 2 insertions(+) diff --git a/Lib/test/test_capi/test_float.py b/Lib/test/test_capi/test_float.py index d71ca1f0c28266..3d4a4ef0e1e0e4 100644 --- a/Lib/test/test_capi/test_float.py +++ b/Lib/test/test_capi/test_float.py @@ -200,6 +200,7 @@ def test_pack_unpack_roundtrip_for_nans(self): signaling = 0 if platform.machine().startswith('parisc'): # HP PA RISC uses 0 for quiet + # https://en.wikipedia.org/wiki/NaN#Encoding signaling = 1 quiet = int(not signaling) if size == 8: diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index bac4bcbe04dcd0..9ea813d662b887 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -920,6 +920,7 @@ def test_half_float(self): # all exponent bits and the msb of the fraction should all be 1. if platform.machine().startswith('parisc'): # HP PA RISC uses 0 for quiet + # https://en.wikipedia.org/wiki/NaN#Encoding expected = 0x7c else: expected = 0x7e From 5e3b7a95d4a6f313ef444481a93490ddfbcec67d Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Oct 2025 14:35:21 +0200 Subject: [PATCH 3/3] Tweak comment --- Lib/test/test_capi/test_float.py | 2 +- Lib/test/test_struct.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_capi/test_float.py b/Lib/test/test_capi/test_float.py index 3d4a4ef0e1e0e4..983b991b4f163d 100644 --- a/Lib/test/test_capi/test_float.py +++ b/Lib/test/test_capi/test_float.py @@ -199,7 +199,7 @@ def test_pack_unpack_roundtrip_for_nans(self): # e.g. https://developercommunity.visualstudio.com/t/155064 signaling = 0 if platform.machine().startswith('parisc'): - # HP PA RISC uses 0 for quiet + # HP PA RISC uses 0 for quiet, see: # https://en.wikipedia.org/wiki/NaN#Encoding signaling = 1 quiet = int(not signaling) diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 9ea813d662b887..75c76a36ee92f5 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -919,7 +919,7 @@ def test_half_float(self): # Check that packing produces a bit pattern representing a quiet NaN: # all exponent bits and the msb of the fraction should all be 1. if platform.machine().startswith('parisc'): - # HP PA RISC uses 0 for quiet + # HP PA RISC uses 0 for quiet, see: # https://en.wikipedia.org/wiki/NaN#Encoding expected = 0x7c else: