Commit 755b385
committed
gh-129005: Fix buffer expansion in _pyio.FileIO.readall
Move to a linear slice append with an iterator which has a length hint.
This is more expensive then PyByteArray_Resize, but I think as efficient
as can get without a new bytearray Python API to resize.
The previous code didn't append as I had intended:
```python
a = bytearray()
>>> a[0:5] = b'\0'
>>> a
bytearray(b'\x00')
>>> a[5:16] = b'\01'
>>> a
bytearray(b'\x00\x01')
>>> len(a)
2
```1 parent d89a5f6 commit 755b385
2 files changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
1686 | 1687 | | |
1687 | 1688 | | |
1688 | 1689 | | |
1689 | | - | |
| 1690 | + | |
| 1691 | + | |
1690 | 1692 | | |
1691 | 1693 | | |
1692 | 1694 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments