Skip to content

Stop reading after the last requested line - #231

Open
Lushiyao5 wants to merge 1 commit into
fabiocaccamo:mainfrom
Lushiyao5:fix/stop-reading-after-requested-line-20261129
Open

Lushiyao5 wants to merge 1 commit into
fabiocaccamo:mainfrom
Lushiyao5:fix/stop-reading-after-requested-line-20261129

Conversation

@Lushiyao5

Copy link
Copy Markdown
Contributor

A bounded read_file_lines call continues iterating to EOF after collecting the requested lines. On a large file this does unnecessary work and can raise a decode error in a distant part the caller did not ask to read. Stop after yielding the inclusive ending line, while preserving the existing decoding and newline handling.

The added regression requests the first two lines of a file with an invalid byte well beyond them. It fails on the base branch. The I/O test module passes with 107 passed and 1 skipped on Python 3.12.

Prepared with assistance from OpenAI Codex.

@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.59%. Comparing base (5c88544) to head (04c1e1b).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #231      +/-   ##
==========================================
+ Coverage   98.52%   98.59%   +0.07%     
==========================================
  Files          13       13              
  Lines         812      856      +44     
==========================================
+ Hits          800      844      +44     
  Misses         12       12              
Flag Coverage Δ
unittests 98.59% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant