You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_pyio.IOBase.readlines(hint) stops one line early when the total size read equals *hint* #161272
IOBase.readlines(hint) is documented so that "no more lines will be read if the total
size (in bytes/characters) of all lines so far exceeds hint" (the _pyio docstring
says the same). _io implements exactly that: Modules/_io/iobase.c breaks on line_length > hint - length, i.e. only once the new total is strictly greater than hint. _pyio.IOBase.readlines() breaks on n >= hint, so it returns one line fewer
whenever the accumulated size is exactly hint:
Thank you for taking the time to open this issue. Python is a community-driven project, and we want it to be a welcoming place to learn and collaborate.
This issue appears to have been written with AI assistance. Please explain your issue in your own words and describe how you checked the information you provided. This helps us understand your issue and leaves more time to address other issues.
Fair enough, I hadn't seen python/steering-council#372 when I filed. Close it if _pyio is going away, no objection.
In my words: _pyio breaks out of readlines() when the running total is >= hint, iobase.c breaks when it's > hint. So for lines of 2, 3 and 4 bytes with hint=2, io gives me two lines and _pyio gives one. I found it by writing a\nbb\nccc\n and calling readlines() on both for hint 1, 2, 3, 5, 9, 0, -1 and None and diffing the lists, they only differ when the total lands exactly on hint. I used an LLM for the English.
Activity
cmaloney commentedon Nov 3, 2026
Currently holding of on
_pyiochanges while python/steering-council#372 is decided.bedevere-app commentedon Nov 3, 2026
Thank you for taking the time to open this issue. Python is a community-driven project, and we want it to be a welcoming place to learn and collaborate.
This issue appears to have been written with AI assistance. Please explain your issue in your own words and describe how you checked the information you provided. This helps us understand your issue and leaves more time to address other issues.
Please read our guidelines for using AI tools.
tsayin4 commentedon Nov 3, 2026
Fair enough, I hadn't seen python/steering-council#372 when I filed. Close it if _pyio is going away, no objection.
In my words: _pyio breaks out of readlines() when the running total is
>= hint, iobase.c breaks when it's> hint. So for lines of 2, 3 and 4 bytes with hint=2, io gives me two lines and _pyio gives one. I found it by writinga\nbb\nccc\nand calling readlines() on both for hint 1, 2, 3, 5, 9, 0, -1 and None and diffing the lists, they only differ when the total lands exactly on hint. I used an LLM for the English.