Skip to content

gh-155850: Fix array unpickling of odd-length 'w' arrays across endianness - #155851

Open
tonghuaroot wants to merge 2 commits into
python:mainfrom
tonghuaroot:fix-array-utf-mformat
Open

gh-155850: Fix array unpickling of odd-length 'w' arrays across endianness#155851
tonghuaroot wants to merge 2 commits into
python:mainfrom
tonghuaroot:fix-array-utf-mformat

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

mformat_descriptors stores the byte size of one item, but the UTF-16 rows
said 4 (actual: 2) and the UTF-32 rows said 8 (actual: 4). The field's only
consumer is the length check on the cross-endian unpickling path, so an
odd-length 'w' array pickled on an opposite-endian machine was rejected
with ValueError: string length not a multiple of item size. The existing
test_unicode used an even-length string; it now also covers an odd length.

… endianness

mformat_descriptors stored a wrong item size for the UTF-16 (4, should be 2)
and UTF-32 (8, should be 4) machine formats. The field gates the cross-endian
unpickling length check, so an odd-length 'w' array pickled on an opposite-
endian machine was rejected with ValueError.
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.

1 participant