[None][fix] missing-wheel SetupError raises UnboundLocalError on a stale from e - #18964
[None][fix] missing-wheel SetupError raises UnboundLocalError on a stale from e#18964Anai-Guo wants to merge 1 commit into
from e#18964Conversation
In setup.py's extract_from_precompiled, the "Failed to get wheel file" SetupError chains `from e`, but `e` is only bound by the `except Exception as e` of the download branch above. On the for/else path `e` is always unbound: a local precompiled file skips the download branch entirely, a successful download catches nothing, and a failed download already raised. Python 3 also deletes the `as` target at the end of the except block. A tar.gz without a TensorRT-LLM/tensorrt_llm-*.whl member therefore fails with `UnboundLocalError: cannot access local variable 'e'` instead of the intended SetupError naming the bad archive. Signed-off-by: Tai An <antai12232931@outlook.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review. WalkthroughThe setup process now raises ChangesSetup error handling
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to Tarballs without a matching wheel now report the intended setup error instead of failing with an unbound local variable error. No current merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
When a precompiled
tar.gzdoes not contain aTensorRT-LLM/tensorrt_llm-*.whlmember,extract_from_precompiledis meant to raise a clearSetupError. Instead it raisesUnboundLocalError, because theraise ... from erefers to anethat is never bound on that path.eis bound only by theexcept Exception as e:above, and it is unbound at thefor/elsein every case:precompiled_locationis a local file — theelse:download branch never runs, soewas never assigned;On top of that, Python 3 deletes the
astarget at the end of theexceptblock, soewould not survive even if it had been bound.Reproduction
Building a
tar.gzthat holds no matching wheel and callingextract_from_precompiledon it:UnboundLocalError: cannot access local variable 'e' where it is not associated with a valueSetupError: Failed to get wheel file from /tmp/.../precompiled.tar.gz.The intended diagnostic is restored, and the operator finds out which archive was bad instead of getting an
UnboundLocalErrorfromsetup.py.Fix
Drop the stale
from e. There is no active exception to chain here — this is a plain validation failure. The other twofrom esites in this file are inside their ownexceptblocks and are left untouched.🤖 Generated with Claude Code
Dev Engineer Review
setup.pynow raisesSetupErrorwhen an archive lacks a matching wheel. The change removes invalid exception chaining and does not alter other exception paths.QA Engineer Review
No test changes.
Per-File QA Perspective
setup.py: Verify that archives without a matching wheel raiseSetupErrorinstead ofUnboundLocalError.