mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
[3.14] gh-130317: Fix SNaN broken tests on HP PA RISC (GH-140452) (#140467)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-130317: Fix SNaN broken tests on HP PA RISC (GH-140452)
While looking at GH-140028, I found some unrelated test regressions in the
3.14 cycle. These seem to all come from GH-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.
[0]: https://grouper.ieee.org/groups/1788/email/msg03272.html
(cherry picked from commit 76fea5596c)
Co-authored-by: Stefano Rivera <stefano@rivera.za.net>
This commit is contained in:
parent
01b52ea5c0
commit
853e5d94eb
2 changed files with 15 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import math
|
||||
import random
|
||||
import platform
|
||||
import sys
|
||||
import unittest
|
||||
import warnings
|
||||
|
|
@ -197,6 +198,10 @@ class CAPIFloatTest(unittest.TestCase):
|
|||
# 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, see:
|
||||
# https://en.wikipedia.org/wiki/NaN#Encoding
|
||||
signaling = 1
|
||||
quiet = int(not signaling)
|
||||
if size == 8:
|
||||
payload = random.randint(signaling, 0x7ffffffffffff)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import gc
|
|||
import math
|
||||
import operator
|
||||
import unittest
|
||||
import platform
|
||||
import struct
|
||||
import sys
|
||||
import weakref
|
||||
|
|
@ -917,10 +918,17 @@ class UnpackIteratorTest(unittest.TestCase):
|
|||
|
||||
# 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, see:
|
||||
# https://en.wikipedia.org/wiki/NaN#Encoding
|
||||
expected = 0x7c
|
||||
else:
|
||||
expected = 0x7e
|
||||
|
||||
packed = struct.pack('<e', math.nan)
|
||||
self.assertEqual(packed[1] & 0x7e, 0x7e)
|
||||
self.assertEqual(packed[1] & 0x7e, expected)
|
||||
packed = struct.pack('<e', -math.nan)
|
||||
self.assertEqual(packed[1] & 0x7e, 0x7e)
|
||||
self.assertEqual(packed[1] & 0x7e, expected)
|
||||
|
||||
# Checks for round-to-even behavior
|
||||
format_bits_float__rounding_list = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue