Skip to content

fix(bindings/python): fix sized File.readline - #8169

Merged
Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-python-readline-size
Aug 27, 2026
Merged

fix(bindings/python): fix sized File.readline#8169
Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-python-readline-size

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Aug 27, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Part of #8159.

Rationale for this change

File.readline(size) initializes its destination buffer with size zero bytes. BufRead::read_until appends the line after those bytes, and the implementation then truncates the buffer using only the appended length. As a result, sized reads return zero bytes while advancing the file cursor.

What changes are included in this PR?

Read sized lines into an empty buffer while retaining the existing take(size) limit. Add a synchronous regression test against io.BytesIO that covers partial lines, newline boundaries, zero-sized reads, cursor progression, and EOF.

Are there any user-facing changes?

Yes. File.readline(size) now returns the bytes read from the file, up to the requested size, instead of zero-filled data.

AI Usage Statement

AI materially assisted with root-cause analysis, implementation, regression-test construction, and local validation. Validation used the memory backend through the shared blocking reader path; the full remote-service behavior matrix was not run.

@Xuanwo
Xuanwo marked this pull request as ready for review August 27, 2026 06:09
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. releases-note/fix The PR fixes a bug or has a title that begins with "fix" labels Aug 27, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 27, 2026
@Xuanwo
Xuanwo merged commit 7c56882 into main Aug 27, 2026
82 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/fix-python-readline-size branch August 27, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants