sendpfast: report a missing tcpreplay instead of UnboundLocalError - #5204
Merged
Merged
Conversation
When tcpreplay could not be started, Popen raised before cmd was bound and the finally block's cmd.communicate() raised UnboundLocalError. ContextManagerSubprocess then logged "execution failed" with that error instead of "Could not execute tcpreplay, is it installed?". AI-Assisted: yes (Claude Code)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5204 +/- ##
==========================================
- Coverage 81.16% 80.87% -0.29%
==========================================
Files 393 393
Lines 98107 98109 +2
==========================================
- Hits 79629 79349 -280
- Misses 18478 18760 +282
🚀 New features to boost your workflow:
|
gpotter2
approved these changes
Sep 28, 2026
Member
|
Thanks for the PR ! |
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.
Description
When tcpreplay can't be started (not installed, or a wrong
conf.prog.tcpreplay),Popenraises beforecmdis bound, and thefinallyblock'scmd.communicate()then raisesUnboundLocalError.ContextManagerSubprocessonly recognisesEnvironmentError, so instead of "Could not execute tcpreplay, is it installed?" the user gets "execution failed" and anUnboundLocalErrortraceback.This initialises
cmdtoNoneand only reads the process output when it actually started. Withconf.prog.tcpreplay = "/nonexistent/tcpreplay"the log now saysCould not execute /nonexistent/tcpreplay, is it installed?. I added a regression test next to the existing sendpfast one that fails on master and passes with the change.test/regression.utsotherwise gives the same results as on master locally (2 unrelated local failures in both).AI-assisted: Claude Code helped find the issue and draft the change. I reviewed the code and ran the tests myself.