Use _print_exception_bltin in excepthook, register source in linecache#7177
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughSwitches sys.excepthook to call an internal traceback builtin and registers executed code objects in linecache during run_string; also adds "bltin" to the cspell dictionary. (41 words) Changes
Sequence Diagram(s)sequenceDiagram
participant VM as "VM (run_string)"
participant PyCode as "PyCode (builtins::PyCode)"
participant Linecache as "linecache._register_code"
VM->>PyCode: create code object from source
VM->>Linecache: call _register_code(code, source, filename)
Linecache-->>VM: confirmation (implicit)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Code has been automatically formatted The code in this PR has been formatted using:
git pull origin _print_exception_bltin |
1d6566f to
76ffed4
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/vm/src/vm/python_run.rs`:
- Around line 31-40: In register_code_in_linecache, change the direct field
access to use the public accessor: replace the use of code.source_path.as_str()
with code.source_path().as_str(); update the call that creates filename (in the
register_code_in_linecache function) so it uses PyCode::source_path() rather
than the private field, keeping the rest of the call to linecache._register_code
unchanged.
- excepthook: call traceback._print_exception_bltin instead of traceback.print_exception to match PyErr_Display behavior - run_string: register compiled code in linecache._interactive_cache so traceback can display source lines and caret indicators - Remove test_sys_tracebacklimit expectedFailure
5baab1d to
27390dc
Compare
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [ ] lib: cpython/Lib/csv.py dependencies:
dependent tests: (2 tests)
[ ] test: cpython/Lib/test/test_sys.py (TODO: 14) dependencies: dependent tests: (212 tests)
[ ] test: cpython/Lib/test/test_unpack.py (TODO: 8) dependencies: dependent tests: (no tests depend on unpack) [x] lib: cpython/Lib/warnings.py dependencies:
dependent tests: (49 tests)
[x] test: cpython/Lib/test/test_winsound.py dependencies: dependent tests: (no tests depend on winsound) Legend:
|
Summary by CodeRabbit
Bug Fixes
Chores