Skip to content

Commit 1d6566f

Browse files
committed
Use _print_exception_bltin in excepthook, register source in linecache
- 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
1 parent 8fa0c66 commit 1d6566f

File tree

4 files changed

+2
-4
lines changed

4 files changed

+2
-4
lines changed

.cspell.dict/cpython.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ badsyntax
1111
baseinfo
1212
basetype
1313
binop
14+
bltin
1415
boolop
1516
BUFMAX
1617
BUILDSTDLIB

Lib/test/test_sys.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,6 @@ def test_getandroidapilevel(self):
12321232
self.assertIsInstance(level, int)
12331233
self.assertGreater(level, 0)
12341234

1235-
@unittest.expectedFailure # TODO: RUSTPYTHON
12361235
@force_not_colorized
12371236
@support.requires_subprocess()
12381237
def test_sys_tracebacklimit(self):

Lib/test/test_warnings/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,6 @@ def test_envvar_and_command_line(self):
14781478
self.assertEqual(stdout,
14791479
b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")
14801480

1481-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: b"['error::DeprecationWarning']" != b"['default::DeprecationWarning', 'error::DeprecationWarning']"
14821481
@force_not_colorized
14831482
def test_conflicting_envvar_and_command_line(self):
14841483
rc, stdout, stderr = assert_python_failure("-Werror::DeprecationWarning", "-c",

crates/vm/src/stdlib/sys.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,7 @@ mod sys {
825825
let stderr = super::get_stderr(vm)?;
826826
match vm.normalize_exception(exc_type.clone(), exc_val.clone(), exc_tb) {
827827
Ok(exc) => {
828-
// Try Python traceback module first for richer output
829-
// (enables features like keyword typo suggestions in SyntaxError)
828+
// PyErr_Display: try traceback._print_exception_bltin first
830829
if let Ok(tb_mod) = vm.import("traceback", 0)
831830
&& let Ok(print_exc) = tb_mod.get_attr("print_exception", vm)
832831
&& print_exc.call((exc.as_object().to_owned(),), vm).is_ok()

0 commit comments

Comments
 (0)