Format: text/x-python
⬇ Download File (1.0 KB)
   1  __all__ = [
   2      "BaseExceptionGroup",
   3      "ExceptionGroup",
   4      "catch",
   5      "format_exception",
   6      "format_exception_only",
   7      "print_exception",
   8      "print_exc",
   9      "suppress",
  10  ]
  11  
  12  import os
  13  import sys
  14  
  15  from ._catch import catch
  16  from ._version import version as __version__  # noqa: F401
  17  
  18  if sys.version_info < (3, 11):
  19      from ._exceptions import BaseExceptionGroup, ExceptionGroup
  20      from ._formatting import (
  21          format_exception,
  22          format_exception_only,
  23          print_exc,
  24          print_exception,
  25      )
  26  
  27      if os.getenv("EXCEPTIONGROUP_NO_PATCH") != "1":
  28          from . import _formatting  # noqa: F401
  29  
  30      BaseExceptionGroup.__module__ = __name__
  31      ExceptionGroup.__module__ = __name__
  32  else:
  33      from traceback import (
  34          format_exception,
  35          format_exception_only,
  36          print_exc,
  37          print_exception,
  38      )
  39  
  40      BaseExceptionGroup = BaseExceptionGroup
  41      ExceptionGroup = ExceptionGroup
  42  
  43  if sys.version_info < (3, 12, 1):
  44      from ._suppress import suppress
  45  else:
  46      from contextlib import suppress
  47