Commit 6261c86
committed
gh-145261: Fix ShareableList corruption for multi-byte strings and bytes with trailing nulls
ShareableList had two bugs:
1. Used character count len(item) instead of byte count
len(item.encode('utf-8')) for string slot allocation, causing
UnicodeDecodeError with multi-byte UTF-8 characters.
2. Used rstrip(b'\x00') to recover bytes values, which stripped
legitimate trailing null bytes.
Fix uses UTF-8 byte length for string allocation and stores the actual
byte length in the format metadata for bytes values, so retrieval reads
exactly the right number of bytes without needing rstrip.1 parent 4401f23 commit 6261c86
2 files changed
+12
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
| 315 | + | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
358 | 363 | | |
359 | 364 | | |
360 | 365 | | |
361 | 366 | | |
362 | | - | |
| 367 | + | |
363 | 368 | | |
364 | 369 | | |
365 | 370 | | |
| |||
476 | 481 | | |
477 | 482 | | |
478 | 483 | | |
479 | | - | |
| 484 | + | |
| 485 | + | |
480 | 486 | | |
481 | 487 | | |
482 | 488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4757 | 4757 | | |
4758 | 4758 | | |
4759 | 4759 | | |
4760 | | - | |
| 4760 | + | |
4761 | 4761 | | |
4762 | 4762 | | |
4763 | 4763 | | |
| |||
4785 | 4785 | | |
4786 | 4786 | | |
4787 | 4787 | | |
4788 | | - | |
| 4788 | + | |
4789 | 4789 | | |
4790 | 4790 | | |
4791 | 4791 | | |
| |||
4817 | 4817 | | |
4818 | 4818 | | |
4819 | 4819 | | |
4820 | | - | |
4821 | 4820 | | |
4822 | 4821 | | |
4823 | 4822 | | |
| |||
0 commit comments