fix: resolve NameError crash at startup by defining argv before use#50
Open
zza-830 wants to merge 2 commits into
Open
fix: resolve NameError crash at startup by defining argv before use#50zza-830 wants to merge 2 commits into
zza-830 wants to merge 2 commits into
Conversation
added 2 commits
June 8, 2026 09:46
The function referenced a bare name that was never imported or defined, causing a NameError crash on every invocation. Fix: move before the conditional block so it is always defined when reached by the comparison at the end of the function. Closes TruFoundation#40
The test_run_help_prints_docstring_for_known_command test was failing because the fake kernel lacked a _import_module method, causing the module import to fail silently and fall through to the error message. Add a working _fake_import_module that uses importlib to resolve the module path, allowing run_help to read and print the docstring.
Collaborator
|
@zza-830 The fix looks clean, but there’s a merge conflict in cli.py (likely clashing with the recent shell injection hardening or the cd env var fixes). Let’s get that resolved first. |
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.
Problem
The
app_with_lower()function intrushell/cli.pyreferences a bare nameargvthat is never imported or defined anywhere in the file. Every invocation from the command line that passes through this branch raises aNameErrorand crashes before the REPL starts.Closes #40
Fix
Moved
argv = sys.argv.copy()before the conditional block so the variable is always defined when reached by the comparison at the end of the function. Also added.lower()to the raw command construction to match the function's documented purpose of normalizing arguments to lowercase.Testing
All 21 existing tests pass (1 pre-existing failure in
test_help_docs.pyunrelated to this change).