FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-43950: ensure source_line is present when specializing the traceback by isidentical · Pull Request #27313 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
25 changes: 25 additions & 0 deletions Lib/test/test_traceback.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ def test_no_caret_with_no_debug_ranges_flag_python_traceback(self):
finally:
unlink(TESTFN)

def test_recursion_error_during_traceback(self):
code = textwrap.dedent("""
import sys
from weakref import ref

sys.setrecursionlimit(15)

def f():
ref(lambda: 0, [])
f()

try:
f()
except RecursionError:
pass
""")
try:
with open(TESTFN, 'w') as f:
f.write(code)

rc, _, _ = assert_python_ok(TESTFN)
self.assertEqual(rc, 0)
finally:
unlink(TESTFN)

def test_bad_indentation(self):
err = self.get_exception_format(self.syntax_error_bad_indentation,
IndentationError)
Expand Down
4 changes: 2 additions & 2 deletions Python/traceback.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,11 @@ tb_displayline(PyTracebackObject* tb, PyObject *f, PyObject *filename, int linen
Py_DECREF(line);
if (err != 0)
return err;

int truncation = _TRACEBACK_SOURCE_LINE_INDENT;
PyObject* source_line = NULL;

if (_Py_DisplaySourceLine(f, filename, lineno, _TRACEBACK_SOURCE_LINE_INDENT,
&truncation, &source_line) != 0) {
&truncation, &source_line) != 0 || !source_line) {
/* ignore errors since we can't report them, can we? */
err = ignore_source_errors();
goto done;
Expand Down

Back | FazBrowse Home | New Git URL