Skip to content

fix: narrow bare excepts around json.loads in python_executor - #95

Open
harshadkhetpal wants to merge 1 commit into
wanxingai:mainfrom
harshadkhetpal:fix/narrow-bare-excepts
Open

fix: narrow bare excepts around json.loads in python_executor#95
harshadkhetpal wants to merge 1 commit into
wanxingai:mainfrom
harshadkhetpal:fix/narrow-bare-excepts

Conversation

@harshadkhetpal

Copy link
Copy Markdown

Summary

Two bare except: clauses in LightAgent/builtin_tools/python_executor.py wrap json.loads fallbacks (ruff E722). A bare except also swallows KeyboardInterrupt / SystemExit and can mask unrelated bugs in the recursive code-cleaning path. Narrowed both to the exceptions json.loads actually raises:

except (json.JSONDecodeError, TypeError):

Behavior for malformed JSON input is unchanged — only the accidental swallowing of process-control exceptions is removed.

Testing

python -m py_compile passes; ruff check --select E722 on the file goes from 2 errors to clean.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Harshad Khetpal <harshadkhetpal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant