MCPcopy Index your code
hub / github.com/ipython/ipython / _get_exc_info

Method _get_exc_info

IPython/core/interactiveshell.py:2114–2146  ·  view source on GitHub ↗

get exc_info from a given tuple, sys.exc_info() or sys.last_type etc. Ensures sys.last_type,value,traceback hold the exc_info we found, from whichever source. raises ValueError if none of these contain any information

(self, exc_tuple=None)

Source from the content-addressed store, hash-verified

2112 self.showtraceback((etype, value, tb), tb_offset=0)
2113
2114 def _get_exc_info(self, exc_tuple=None):
2115 """get exc_info from a given tuple, sys.exc_info() or sys.last_type etc.
2116
2117 Ensures sys.last_type,value,traceback hold the exc_info we found,
2118 from whichever source.
2119
2120 raises ValueError if none of these contain any information
2121 """
2122 if exc_tuple is None:
2123 etype, value, tb = sys.exc_info()
2124 else:
2125 etype, value, tb = exc_tuple
2126
2127 if etype is None:
2128 if hasattr(sys, 'last_type'):
2129 etype, value, tb = sys.last_type, sys.last_value, \
2130 sys.last_traceback
2131
2132 if etype is None:
2133 raise ValueError("No exception to find")
2134
2135 # Now store the exception info in sys.last_type etc.
2136 # WARNING: these variables are somewhat deprecated and not
2137 # necessarily safe to use in a threaded environment, but tools
2138 # like pdb depend on their existence, so let's set them. If we
2139 # find problems in the field, we'll need to revisit their use.
2140 sys.last_type = etype
2141 sys.last_value = value
2142 sys.last_traceback = tb
2143 if sys.version_info >= (3, 12):
2144 sys.last_exc = value
2145
2146 return etype, value, tb
2147
2148 def show_usage_error(self, exc):
2149 """Show a short message for UsageErrors

Callers 4

get_exception_onlyMethod · 0.95
showtracebackMethod · 0.95
showsyntaxerrorMethod · 0.95
_user_obj_errorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected