fix: resolve NameError crash at startup by defining argv before use#50
fix: resolve NameError crash at startup by defining argv before use#50zza-830 wants to merge 2 commits into
Conversation
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.
|
@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. |
|
Resolve the merge conflict in cli.py by rebasing onto main. And verify that the .lower() change doesn’t break case-sensitive paths. Fix this, and it's all good! |
|
After the rust-refactor, we have removed all the python code, and it's bugs along with it. |
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).