Commit 30d9822
committed
gh-154568: Fix array._array_reconstructor() ignoring requested byte order for float16
The slow-path decoder for IEEE_754_FLOAT16_LE/BE computed the
byte-order flag by comparing mformat_code against IEEE_754_FLOAT_LE
(the 32-bit float constant) instead of IEEE_754_FLOAT16_LE. Since the
float16 mformat codes are never equal to that constant, the comparison
was always false, so the decoder always treated input as big-endian
regardless of what was requested.
Adds a regression test. A real 'e'-typecode array only exercises the
slow/converting path when the requested mformat disagrees with the
machine's native float16 format, so which direction (LE/BE) exercises
the buggy branch depends on the test machine's endianness, and the
other direction happens to come out "correct" by coincidence since the
bug unconditionally decodes as big-endian. The test uses a typecode
('d') whose native format can never match the float16 codes, forcing
the slow path deterministically on any machine.1 parent 66e313f commit 30d9822
3 files changed
Lines changed: 31 additions & 1 deletion
File tree
- Lib/test
- Misc/NEWS.d/next/Library
- Modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
242 | 264 | | |
243 | 265 | | |
244 | 266 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2281 | 2281 | | |
2282 | 2282 | | |
2283 | 2283 | | |
2284 | | - | |
| 2284 | + | |
2285 | 2285 | | |
2286 | 2286 | | |
2287 | 2287 | | |
| |||
0 commit comments