Repository navigation
gh-163051: Fix ShareableList layout for empty str/bytes - #163052
hyongtao-code wants to merge 4 commits into
Conversation
|
Could the regression also construct a list whose initial last element is empty, e.g. As an earlier-runtime control, I ran all four constructor cases on CPython 3.12.16/Linux, attached a second Testing constructor-time trailing empties plus reading the attached-by-name view after mutation would cover both metadata survival and layout reconstruction. This is proposed coverage after source review, not a reproduction of the 3.16 failure or execution of this PR build. AI-assisted investigation; the 3.12 control was run locally. |
An empty str/bytes was given a zero-length slot: the item size is now
computed as a ceiling division,
which yields 0 when len(encoded) == 0. The item then shares its offset
with the next item, or with the packing-format metadata when it is the
last one, so filling that slot either raises a misleading ValueError or
silently overwrites the neighbour (and, in the trailing case, destroys
the block). Clamp the result to one alignment unit.
The layout of non-empty items is unchanged, so blocks created by earlier
releases keep working.
Add a regression test covering empty str and bytes in the first, middle
and last position.
Signed-off-by: Yongtao Huang yongtaoh2022@gmail.com