File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 11import math
22import random
3- import platform
43import sys
54import unittest
65import warnings
@@ -215,8 +214,8 @@ def test_pack_unpack_roundtrip_for_nans(self):
215214 # PyFloat_Pack/Unpack*() API. See also gh-130317 and
216215 # e.g. https://developercommunity.visualstudio.com/t/155064
217216 signaling = 0
218- if platform . machine (). startswith ( 'parisc' ) :
219- # HP PA RISC uses 0 for quiet, see:
217+ if _testcapi . nan_msb_is_signaling :
218+ # HP PA RISC and some MIPS CPUs use 0 for quiet, see:
220219 # https://en.wikipedia.org/wiki/NaN#Encoding
221220 signaling = 1
222221 i = make_nan (size , sign , not signaling )
Original file line number Diff line number Diff line change 55import math
66import operator
77import unittest
8- import platform
98import struct
109import sys
1110import weakref
@@ -891,6 +890,7 @@ def test_module_func(self):
891890 self .assertRaises (StopIteration , next , it )
892891
893892 def test_half_float (self ):
893+ _testcapi = import_helper .import_module ('_testcapi' )
894894 # Little-endian examples from:
895895 # http://en.wikipedia.org/wiki/Half_precision_floating-point_format
896896 format_bits_float__cleanRoundtrip_list = [
@@ -935,8 +935,8 @@ def test_half_float(self):
935935
936936 # Check that packing produces a bit pattern representing a quiet NaN:
937937 # all exponent bits and the msb of the fraction should all be 1.
938- if platform . machine (). startswith ( 'parisc' ) :
939- # HP PA RISC uses 0 for quiet, see:
938+ if _testcapi . nan_msb_is_signaling :
939+ # HP PA RISC and some MIPS CPUs use 0 for quiet, see:
940940 # https://en.wikipedia.org/wiki/NaN#Encoding
941941 expected = 0x7c
942942 else :
Original file line number Diff line number Diff line change @@ -171,5 +171,9 @@ _PyTestCapi_Init_Float(PyObject *mod)
171171 return -1 ;
172172 }
173173
174- return 0 ;
174+ #if (defined(__mips__ ) && !defined(__mips_nan2008 )) || defined(__hppa__ )
175+ return PyModule_Add (mod , "nan_msb_is_signaling" , PyBool_FromLong (1 ));
176+ #else
177+ return PyModule_Add (mod , "nan_msb_is_signaling" , PyBool_FromLong (0 ));
178+ #endif
175179}
You can’t perform that action at this time.
0 commit comments