Skip to content

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

Open
miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-f3be08a-3.15
Open

[3.15] gh-154568: Fix array unpickling of little-endian float16 (GH-154569)#155557
miss-islington wants to merge 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants