Skip to content

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

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

cmaloney merged 1 commit into
python:3.14from
cmaloney:backport-ad126c9-3.14

Conversation

@cmaloney

@cmaloney cmaloney 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)

… past end 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 679b376 into python:3.14 Nov 9, 2026
51 checks passed
@cmaloney
cmaloney deleted the backport-ad126c9-3.14 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.

2 participants