Skip to content

[3.15] gh-160811: fix TextIOWrapper.tell() after seek() reading past end of buffer (GH-160812) - #161702

Merged
cmaloney merged 1 commit into
python:3.15from
miss-islington:backport-ad126c9-3.15
Nov 9, 2026
Merged

cmaloney merged 1 commit into
python:3.15from
miss-islington:backport-ad126c9-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

TextIOWrapper keeps a "bytes to character" ratio as a float so it can optimize operations. If that got to NaN or Infinity as a value then .tell() could compute skip_bytes larger than the snapshot buffer. In the C implementation this read past the end of the buffer, and _pyio returned a wrong position.
(cherry picked from commit ad126c9)

Co-authored-by: tonghuaroot (童话) tonghuaroot@gmail.com

…nd of buffer (pythonGH-160812)

TextIOWrapper keeps a "bytes to character" ratio as a float so it can optimize operations. If that got to NaN or Infinity as a value then `.tell()` could compute `skip_bytes` larger than the snapshot buffer. In the C implementation this read past the end of the buffer, and _pyio returned a wrong position.
(cherry picked from commit ad126c9)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
@cmaloney
cmaloney merged commit d8f6384 into python:3.15 Nov 9, 2026
56 checks passed
@miss-islington
miss-islington deleted the backport-ad126c9-3.15 branch November 9, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants