Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Lib/test/test_capi/test_float.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import math
import random
import platform
import sys
import unittest
import warnings
Expand Down Expand Up @@ -215,8 +214,8 @@ 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, see:
if _testcapi.nan_msb_is_signaling:
# HP PA RISC and some MIPS CPUs use 0 for quiet, see:
# https://en.wikipedia.org/wiki/NaN#Encoding
signaling = 1
i = make_nan(size, sign, not signaling)
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import math
import operator
import unittest
import platform
import struct
import sys
import weakref
Expand Down Expand Up @@ -891,6 +890,7 @@ def test_module_func(self):
self.assertRaises(StopIteration, next, it)

def test_half_float(self):
_testcapi = import_helper.import_module('_testcapi')
# Little-endian examples from:
# http://en.wikipedia.org/wiki/Half_precision_floating-point_format
format_bits_float__cleanRoundtrip_list = [
Expand Down Expand Up @@ -935,8 +935,8 @@ 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, see:
if _testcapi.nan_msb_is_signaling:
# HP PA RISC and some MIPS CPUs use 0 for quiet, see:
# https://en.wikipedia.org/wiki/NaN#Encoding
expected = 0x7c
else:
Expand Down
6 changes: 5 additions & 1 deletion Modules/_testcapi/float.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,9 @@ _PyTestCapi_Init_Float(PyObject *mod)
return -1;
}

return 0;
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return PyModule_Add(mod, "nan_msb_is_signaling", PyBool_FromLong(1));
#else
return PyModule_Add(mod, "nan_msb_is_signaling", PyBool_FromLong(0));
#endif
}
Loading