Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ class TestTracebackFormat(unittest.TestCase, TracebackFormatMixin):

@cpython_only
@force_not_colorized_test_class
class TestFallbackTracebackFormat(unittest.TestCase, TracebackFormatMixin):
class TestFallbackFormatWhenPrinterRaises(unittest.TestCase, TracebackFormatMixin):
Comment thread
johnslavik marked this conversation as resolved.
Outdated
DEBUG_RANGES = False
def setUp(self) -> None:
self.original_unraisable_hook = sys.unraisablehook
Expand All @@ -2282,6 +2282,34 @@ def tearDown(self) -> None:
sys.unraisablehook = self.original_unraisable_hook
return super().tearDown()

@cpython_only
@force_not_colorized_test_class
class TestFallbackFormatWhenIOUnavailable(unittest.TestCase, TracebackFormatMixin):
def setUp(self) -> None:
import io
self.original_io = io
self.original_hook = traceback._print_exception_bltin
traceback._print_exception_bltin = object()
sys.modules['io'] = types.SimpleNamespace(StringIO=io.StringIO)
return super().setUp()

Comment thread
johnslavik marked this conversation as resolved.
Outdated
def test_unhashable(self):
raise unittest.SkipTest(
"test requires source lines to be captured in tracebacks")

def test_traceback_format_with_cleared_frames(self):
raise unittest.SkipTest(
"test requires source lines to be captured in tracebacks")

def test_traceback_format(self):
raise unittest.SkipTest(
"test requires source lines to be captured in tracebacks")

def tearDown(self) -> None:
sys.modules['io'] = self.original_io
traceback._print_exception_bltin = self.original_hook
return super().tearDown()

class BaseExceptionReportingTests:

def get_exception(self, exception_or_callable):
Expand Down
3 changes: 3 additions & 0 deletions Objects/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ _Py_COMP_DIAG_POP
PyObject * _PyObject_CallMethodFormat(PyThreadState *tstate, PyObject *callable,
const char *format, ...)
{
if (callable == NULL) {
return NULL;
}
Comment thread
johnslavik marked this conversation as resolved.
Outdated
va_list va;
va_start(va, format);
PyObject *retval = callmethod(tstate, callable, format, va);
Expand Down
Loading