##// END OF EJS Templates
fall back to native when printing an ExceptionGroup
jakkdl -
Show More
@@ -112,6 +112,8 b' try:'
112 except ImportError:
112 except ImportError:
113 sphinxify = None
113 sphinxify = None
114
114
115 if sys.version_info[:2] < (3, 11):
116 from exceptiongroup import BaseExceptionGroup
115
117
116 class ProvisionalWarning(DeprecationWarning):
118 class ProvisionalWarning(DeprecationWarning):
117 """
119 """
@@ -2095,25 +2097,38 b' class InteractiveShell(SingletonConfigurable):'
2095 stb.extend(self.InteractiveTB.get_exception_only(etype,
2097 stb.extend(self.InteractiveTB.get_exception_only(etype,
2096 value))
2098 value))
2097 else:
2099 else:
2098 try:
2099 # Exception classes can customise their traceback - we
2100 # use this in IPython.parallel for exceptions occurring
2101 # in the engines. This should return a list of strings.
2102 if hasattr(value, "_render_traceback_"):
2103 stb = value._render_traceback_()
2104 else:
2105 stb = self.InteractiveTB.structured_traceback(
2106 etype, value, tb, tb_offset=tb_offset
2107 )
2108
2100
2109 except Exception:
2101 def contains_exceptiongroup(val):
2110 print(
2102 if val is None:
2111 "Unexpected exception formatting exception. Falling back to standard exception"
2103 return False
2112 )
2104 return isinstance(
2105 val, BaseExceptionGroup
2106 ) or contains_exceptiongroup(val.__context__)
2107
2108 if contains_exceptiongroup(value):
2109 # fall back to native exception formatting until ultratb
2110 # supports exception groups
2113 traceback.print_exc()
2111 traceback.print_exc()
2114 return None
2112 else:
2113 try:
2114 # Exception classes can customise their traceback - we
2115 # use this in IPython.parallel for exceptions occurring
2116 # in the engines. This should return a list of strings.
2117 if hasattr(value, "_render_traceback_"):
2118 stb = value._render_traceback_()
2119 else:
2120 stb = self.InteractiveTB.structured_traceback(
2121 etype, value, tb, tb_offset=tb_offset
2122 )
2123
2124 except Exception:
2125 print(
2126 "Unexpected exception formatting exception. Falling back to standard exception"
2127 )
2128 traceback.print_exc()
2129 return None
2115
2130
2116 self._showtraceback(etype, value, stb)
2131 self._showtraceback(etype, value, stb)
2117 if self.call_pdb:
2132 if self.call_pdb:
2118 # drop into debugger
2133 # drop into debugger
2119 self.debugger(force=True)
2134 self.debugger(force=True)
General Comments 0
You need to be logged in to leave comments. Login now