MCPcopy Index your code
hub / github.com/python/cpython / build_excinfo

Function build_excinfo

Lib/test/test_interpreters/test_api.py:62–89  ·  view source on GitHub ↗
(exctype, msg=None, formatted=None, errdisplay=None)

Source from the content-addressed store, hash-verified

60
61
62def build_excinfo(exctype, msg=None, formatted=None, errdisplay=None):
63 if isinstance(exctype, type):
64 assert issubclass(exctype, BaseException), exctype
65 exctype = types.SimpleNamespace(
66 __name__=exctype.__name__,
67 __qualname__=exctype.__qualname__,
68 __module__=exctype.__module__,
69 )
70 elif isinstance(exctype, str):
71 module, _, name = exctype.rpartition(exctype)
72 if not module and name in __builtins__:
73 module = 'builtins'
74 exctype = types.SimpleNamespace(
75 __name__=name,
76 __qualname__=exctype,
77 __module__=module or None,
78 )
79 else:
80 assert isinstance(exctype, types.SimpleNamespace)
81 assert msg is None or isinstance(msg, str), msg
82 assert formatted is None or isinstance(formatted, str), formatted
83 assert errdisplay is None or isinstance(errdisplay, str), errdisplay
84 return types.SimpleNamespace(
85 type=exctype,
86 msg=msg,
87 formatted=formatted,
88 errdisplay=errdisplay,
89 )
90
91
92class ModuleTests(TestBase):

Callers 2

test_execMethod · 0.85
test_callMethod · 0.85

Calls 1

rpartitionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…