MCPcopy Create free account
hub / github.com/ipython/ipython / wrapped

Method wrapped

IPython/core/interactiveshell.py:1910–1930  ·  view source on GitHub ↗

wrap CustomTB handler, to protect IPython from user code This makes it harder (but not impossible) for custom exception handlers to crash IPython.

(self,etype,value,tb,tb_offset=None)

Source from the content-addressed store, hash-verified

1908 wrapped = dummy_handler
1909 else:
1910 def wrapped(self,etype,value,tb,tb_offset=None):
1911 """wrap CustomTB handler, to protect IPython from user code
1912
1913 This makes it harder (but not impossible) for custom exception
1914 handlers to crash IPython.
1915 """
1916 try:
1917 stb = handler(self,etype,value,tb,tb_offset=tb_offset)
1918 return validate_stb(stb)
1919 except:
1920 # clear custom handler immediately
1921 self.set_custom_exc((), None)
1922 print("Custom TB Handler failed, unregistering", file=sys.stderr)
1923 # show the exception in handler first
1924 stb = self.InteractiveTB.structured_traceback(*sys.exc_info())
1925 print(self.InteractiveTB.stb2text(stb))
1926 print("The original exception:")
1927 stb = self.InteractiveTB.structured_traceback(
1928 (etype,value,tb), tb_offset=tb_offset
1929 )
1930 return stb
1931
1932 self.CustomTB = types.MethodType(wrapped,self)
1933 self.custom_exceptions = exc_tuple

Callers

nothing calls this directly

Calls 3

set_custom_excMethod · 0.95
structured_tracebackMethod · 0.45
stb2textMethod · 0.45

Tested by

no test coverage detected