Skip to content

[3.15] gh-154568: Fix array unpickling of little-endian float16 (GH-154569) - #155557

Merged
hugovk merged 1 commit into
python:3.15from
miss-islington:backport-f3be08a-3.15
Aug 12, 2026
Merged

[3.15] gh-154568: Fix array unpickling of little-endian float16 (GH-154569)#155557
hugovk merged 1 commit into
python:3.15from
miss-islington:backport-f3be08a-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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.
(cherry picked from commit f3be08a)

Co-authored-by: PhysicistJohn 54456354+PhysicistJohn@users.noreply.github.com

…nGH-154569)

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.
(cherry picked from commit f3be08a)

Co-authored-by: PhysicistJohn <54456354+PhysicistJohn@users.noreply.github.com>

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hugovk
hugovk merged commit ad09d00 into python:3.15 Aug 12, 2026
60 checks passed
@miss-islington
miss-islington deleted the backport-f3be08a-3.15 branch August 12, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants