Repository navigation
python: propagate the real error for unseekable streams in identify_stream (#1473) - #1475
Open
kaluli123123 wants to merge 4 commits into
Open
kaluli123123 wants to merge 4 commits into
kaluli123123 wants to merge 4 commits into
Conversation
…tream `identify_stream()` bound `current_position` inside the `try` block but referenced it unconditionally in `finally`. For a readable-but-unseekable binary stream (e.g. `sys.stdin.buffer` on a pipe) `stream.tell()` raises, so the name was never bound and `finally` raised `UnboundLocalError`, demoting the actionable `OSError` to `__context__`. Hoist `tell()` out of the `try` block: there is nothing to restore until the position is known, and the only statement left inside `try` is the one that needs the restore. Fixes google#1473
Resolve the conflict in identify_stream() against the new stream-reading logic from main: keep main's block-based read, and keep this PR's fix of calling tell() before the try block so the real error of an unseekable stream is not masked by an UnboundLocalError.
Author
|
Merged current Checks run locally in |
1 of 7 tasks
Collaborator
|
Thank you! I checked this against the current |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1473.
Queries the stream position before entering the restoring
try/finally, preserving the original unseekable-stream error. Includes regression coverage and mergesmainat8d3d3b9without expanding the fix.Python 3.13 validation: both stream regressions passed; non-slow suite 41 passed / 1 skipped; lock, Ruff, formatting, mypy, copyright and CLI/module smokes passed. A real OS pipe propagated
ESPIPE; seekable stream positions remained unchanged.Broader baseline checks exposed a macOS FFI linker error and a regenerated model-probe mismatch; no Rust/model changes are included. Formal approval and current-head upstream CI remain required.