Skip to content

Commit

Permalink
Remove special handling due to IPython lacking support for exception …
Browse files Browse the repository at this point in the history
…groups
  • Loading branch information
jakkdl authored and TeamSpen210 committed Sep 5, 2023
1 parent 1c15500 commit 761ec2a
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions trio/_core/_multierror.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
from trio._deprecate import warn_deprecated

if sys.version_info < (3, 11):
from exceptiongroup import BaseExceptionGroup, ExceptionGroup, print_exception
else:
from traceback import print_exception
from exceptiongroup import BaseExceptionGroup, ExceptionGroup

if TYPE_CHECKING:
from typing_extensions import Self
Expand Down Expand Up @@ -461,37 +459,6 @@ def concat_tb(
return current_head


# Remove when IPython gains support for exception groups
# (https://github.com/ipython/ipython/issues/13753)
if "IPython" in sys.modules:
import IPython

ip = IPython.get_ipython()
if ip is not None:
if ip.custom_exceptions != ():
warnings.warn(
"IPython detected, but you already have a custom exception "
"handler installed. I'll skip installing Trio's custom "
"handler, but this means exception groups will not show full "
"tracebacks.",
category=RuntimeWarning,
)
else:

def trio_show_traceback(
self: IPython.core.interactiveshell.InteractiveShell,
etype: type[BaseException],
value: BaseException,
tb: TracebackType,
tb_offset: int | None = None,
) -> None:
# XX it would be better to integrate with IPython's fancy
# exception formatting stuff (and not ignore tb_offset)
print_exception(value)

ip.set_custom_exc((BaseExceptionGroup,), trio_show_traceback)


# Ubuntu's system Python has a sitecustomize.py file that import
# apport_python_hook and replaces sys.excepthook.
#
Expand Down

0 comments on commit 761ec2a

Please sign in to comment.