Skip to content

Commit e8631d1

Browse files
committed
Address review feedback: add half-floats case to test_numbers(), simplify NEWS wording
Per skirpichev's review on GH-154569: - Add a float16 (LE/BE) case to ArrayReconstructorTest.test_numbers() for basic functional coverage alongside the other numeric types, complementing the existing dedicated test_float16_endianness (which he confirmed is fine to keep for deterministically forcing the buggy slow path regardless of test-machine endianness). - Simplify the NEWS entry wording per his suggested rewrite.
1 parent fc94566 commit e8631d1

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

Lib/test/test_array.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ def test_numbers(self):
209209
[-1<<63, (1<<63)-1, 0]),
210210
(['l'], SIGNED_INT64_BE, '>qqq',
211211
[-1<<63, (1<<63)-1, 0]),
212+
(['e'], IEEE_754_FLOAT16_LE, '<eeee',
213+
[1.0, float('inf'), float('-inf'), -0.0]),
214+
(['e'], IEEE_754_FLOAT16_BE, '>eeee',
215+
[1.0, float('inf'), float('-inf'), -0.0]),
212216
(['f'], IEEE_754_FLOAT_LE, '<ffff',
213217
[16711938.0, float('inf'), float('-inf'), -0.0]),
214218
(['f'], IEEE_754_FLOAT_BE, '>ffff',
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
Fix ``array._array_reconstructor`` (used internally for unpickling
2-
:class:`array.array`) ignoring the requested byte order for the
3-
``IEEE_754_FLOAT16_LE``/``IEEE_754_FLOAT16_BE`` machine format codes: it
4-
compared against the 32-bit float constant instead of the float16 one, so
5-
it always decoded as big-endian regardless of what was requested. This
6-
could silently produce wrong values when unpickling an ``'e'``-typecode
7-
(half precision float) array on a machine with different native
8-
endianness than the one that pickled it.
2+
:class:`array.array`) ignoring the requested byte order and always
3+
decoded as big-endian. This could silently produce wrong values when
4+
unpickling a half precision float array on a machine with different
5+
native endianness than the one that pickled it.

0 commit comments

Comments
 (0)