aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/core/interactiveshell.py
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2023-09-30 10:27:28 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2023-09-30 10:47:10 +0300
commit5a6373c9d09bbfb7094f9992a4531477bb97829e (patch)
treeebea8fd55fee858876743312cdf789a1f01487b5 /contrib/python/ipython/py3/IPython/core/interactiveshell.py
parent15f3c7493474de25a6b23296878bb8f49470d2e6 (diff)
downloadydb-5a6373c9d09bbfb7094f9992a4531477bb97829e.tar.gz
Update contrib/python/ipython/py3 to 8.15.0
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/interactiveshell.py')
-rw-r--r--contrib/python/ipython/py3/IPython/core/interactiveshell.py58
1 files changed, 38 insertions, 20 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/interactiveshell.py b/contrib/python/ipython/py3/IPython/core/interactiveshell.py
index 7392de7c02..894403f98b 100644
--- a/contrib/python/ipython/py3/IPython/core/interactiveshell.py
+++ b/contrib/python/ipython/py3/IPython/core/interactiveshell.py
@@ -112,6 +112,8 @@ try:
except ImportError:
sphinxify = None
+if sys.version_info[:2] < (3, 11):
+ from exceptiongroup import BaseExceptionGroup
class ProvisionalWarning(DeprecationWarning):
"""
@@ -2095,25 +2097,38 @@ class InteractiveShell(SingletonConfigurable):
stb.extend(self.InteractiveTB.get_exception_only(etype,
value))
else:
- try:
- # Exception classes can customise their traceback - we
- # use this in IPython.parallel for exceptions occurring
- # in the engines. This should return a list of strings.
- if hasattr(value, "_render_traceback_"):
- stb = value._render_traceback_()
- else:
- stb = self.InteractiveTB.structured_traceback(
- etype, value, tb, tb_offset=tb_offset
- )
- except Exception:
- print(
- "Unexpected exception formatting exception. Falling back to standard exception"
- )
+ def contains_exceptiongroup(val):
+ if val is None:
+ return False
+ return isinstance(
+ val, BaseExceptionGroup
+ ) or contains_exceptiongroup(val.__context__)
+
+ if contains_exceptiongroup(value):
+ # fall back to native exception formatting until ultratb
+ # supports exception groups
traceback.print_exc()
- return None
+ else:
+ try:
+ # Exception classes can customise their traceback - we
+ # use this in IPython.parallel for exceptions occurring
+ # in the engines. This should return a list of strings.
+ if hasattr(value, "_render_traceback_"):
+ stb = value._render_traceback_()
+ else:
+ stb = self.InteractiveTB.structured_traceback(
+ etype, value, tb, tb_offset=tb_offset
+ )
- self._showtraceback(etype, value, stb)
+ except Exception:
+ print(
+ "Unexpected exception formatting exception. Falling back to standard exception"
+ )
+ traceback.print_exc()
+ return None
+
+ self._showtraceback(etype, value, stb)
if self.call_pdb:
# drop into debugger
self.debugger(force=True)
@@ -2417,7 +2432,7 @@ class InteractiveShell(SingletonConfigurable):
result = fn(*args, **kwargs)
# The code below prevents the output from being displayed
- # when using magics with decodator @output_can_be_silenced
+ # when using magics with decorator @output_can_be_silenced
# when the last Python token in the expression is a ';'.
if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
if DisplayHook.semicolon_at_end_of_expression(magic_arg_s):
@@ -2478,7 +2493,7 @@ class InteractiveShell(SingletonConfigurable):
result = fn(*args, **kwargs)
# The code below prevents the output from being displayed
- # when using magics with decodator @output_can_be_silenced
+ # when using magics with decorator @output_can_be_silenced
# when the last Python token in the expression is a ';'.
if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
if DisplayHook.semicolon_at_end_of_expression(cell):
@@ -3338,8 +3353,11 @@ class InteractiveShell(SingletonConfigurable):
# an InputRejected. Short-circuit in this case so that we
# don't unregister the transform.
raise
- except Exception:
- warn("AST transformer %r threw an error. It will be unregistered." % transformer)
+ except Exception as e:
+ warn(
+ "AST transformer %r threw an error. It will be unregistered. %s"
+ % (transformer, e)
+ )
self.ast_transformers.remove(transformer)
if self.ast_transformers: