GeezerVison is showing github.com — Use _print_exception_bltin in excepthook, register source in linecache by youknowone · Pull Request #7177 · RustPython/RustPython
Conversation
youknowone
commented
Feb 17, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
- 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
Summary by CodeRabbit
-
Bug Fixes
- Improved exception traceback output for clearer error messages.
- Enhanced debugging by registering executed source so stack traces show more accurate line information.
-
Chores
- Updated spell-check dictionary with an additional symbol.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Feb 17, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Caution
Review failed
The pull request is closed.
📝 Walkthrough
Walkthrough
Switches 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
| Cohort / File(s) |
Summary |
Dictionary /.cspell.dict/cpython.txt |
Added the token bltin to the spell-check dictionary. |
Exception handling crates/vm/src/stdlib/sys.rs |
excepthook now imports traceback and calls traceback._print_exception_bltin before falling back to the Rust-level printing path. |
Code execution / linecache crates/vm/src/vm/python_run.rs |
In run_string, registers created PyCode in linecache via a new private helper that calls linecache._register_code(code, source, filename). Added type imports to support this. |
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)
Loading
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
🐰 A nibble, a hop, a humble small spin,
I tucked code in cache and let tracebacks begin,
"bltin" now whispers in dictionary light,
Exceptions dress neat for a clearer sight. 🥕
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title accurately captures both main changes: switching to _print_exception_bltin in excepthook and registering source in linecache. |
| Docstring Coverage |
✅ Passed |
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
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.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Code has been automatically formatted
The code in this PR has been formatted using:
cargo fmt --all
Please pull the latest changes before pushing again:
git pull origin _print_exception_bltin
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- 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
Uh oh!
There was an error while loading. Please reload this page.
📦 Library Dependencies
The following Lib/ modules were modified. Here are their dependencies:
[ ] lib: cpython/Lib/csv.py
[ ] test: cpython/Lib/test/test_csv.py (TODO: 27)
dependencies:
dependent tests: (2 tests)
- csv: test_csv test_genericalias
[ ] test: cpython/Lib/test/test_sys.py (TODO: 14)
[ ] test: cpython/Lib/test/test_syslog.py (TODO: 2)
[ ] test: cpython/Lib/test/test_sys_setprofile.py (TODO: 14)
[ ] test: cpython/Lib/test/test_sys_settrace.py (TODO: 85)
dependencies:
dependent tests: (212 tests)
- sys: regrtestdata test___all__ test__colorize test__locale test__osx_support test_android test_annotationlib test_argparse test_array test_ast test_asyncio test_audit test_bdb test_bigaddrspace test_bigmem test_bisect test_buffer test_builtin test_bytes test_bz2 test_c_locale_coercion test_calendar test_call test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_code_module test_codeccallbacks test_codecs test_collections test_compile test_compileall test_complex test_concurrent_futures test_context test_contextlib test_coroutines test_csv test_ctypes test_datetime test_dbm test_dbm_sqlite3 test_descr test_dict test_difflib test_dis test_doctest test_doctest2 test_docxmlrpc test_dtrace test_dynamic test_dynamicclassattribute test_email test_ensurepip test_enum test_enumerate test_eof test_except_star test_exceptions test_faulthandler test_fcntl test_file test_file_eintr test_fileinput test_fileio test_float test_fork1 test_format test_fractions test_frozen test_functools test_future_stmt test_generators test_genericpath test_getopt test_glob test_grammar test_gzip test_hash test_hashlib test_http_cookiejar test_httpservers test_importlib test_inspect test_int test_io test_iter test_itertools test_json test_largefile test_launcher test_list test_locale test_logging test_long test_lzma test_mailbox test_marshal test_math test_memoryio test_memoryview test_metaclass test_mimetypes test_mmap test_msvcrt test_multiprocessing_fork test_multiprocessing_main_handling test_ntpath test_numeric_tower test_operator test_optparse test_ordered_dict test_os test_osx_env test_pathlib test_patma test_peepholer test_pickle test_pkg test_pkgutil test_platform test_plistlib test_posix test_posixpath test_print test_property test_pty test_pwd test_py_compile test_pyclbr test_pydoc test_pyexpat test_quopri test_raise test_range test_re test_regrtest test_repl test_reprlib test_resource test_runpy test_script_helper test_select test_selectors test_shutil test_signal test_site test_slice test_smtplib test_socket test_sqlite3 test_ssl test_stat test_statistics test_str test_strftime test_string_literals test_strtod test_struct test_subprocess test_support test_symtable test_sys test_sys_setprofile test_sys_settrace test_sysconfig test_syslog test_tarfile test_tempfile test_termios test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeit test_tomllib test_tools test_trace test_traceback test_type_comments test_types test_typing test_unicode_file test_unicode_file_functions test_unicodedata test_unittest test_univnewlines test_urllib test_urllib2 test_urllib2net test_urlparse test_utf8_mode test_uuid test_venv test_wait3 test_wait4 test_wave test_weakref test_webbrowser test_winconsoleio test_with test_wsgiref test_xml_etree test_xmlrpc test_zipapp test_zipfile test_zipfile64 test_zipimport test_zlib
[ ] test: cpython/Lib/test/test_unpack.py (TODO: 8)
[ ] test: cpython/Lib/test/test_unpack_ex.py (TODO: 11)
dependencies:
dependent tests: (no tests depend on unpack)
[x] lib: cpython/Lib/warnings.py
[x] lib: cpython/Lib/_py_warnings.py
[ ] test: cpython/Lib/test/test_warnings (TODO: 13)
dependencies:
dependent tests: (49 tests)
- warnings: test_argparse test_array test_asyncio test_buffer test_builtin test_codecs test_codeop test_coroutines test_ctypes test_decimal test_descr test_fnmatch test_fstring test_funcattrs test_genericpath test_glob test_global test_grammar test_gzip test_hashlib test_hmac test_importlib test_inspect test_io test_logging test_ntpath test_os test_pickle test_posix test_pty test_pyclbr test_random test_re test_runpy test_set test_socket test_sqlite3 test_str test_string_literals test_support test_sys test_tempfile test_threading test_typing test_unicode_file_functions test_unittest test_unparse test_xml_etree test_zipimport
[x] test: cpython/Lib/test/test_winsound.py
dependencies:
dependent tests: (no tests depend on winsound)
Legend:
[+] path exists in CPython
[x] up-to-date, [ ] outdated
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
youknowone
added a commit
to youknowone/RustPython
that referenced
this pull request
Mar 22, 2026
RustPython#7177)
- 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
youknowone
added a commit
that referenced
this pull request
Sep 16, 2026
#7177)
- 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
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|