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
12import os
13import sys
14
15from ._catch import catch
16from ._version import version as __version__ # noqa: F401
17
18if 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__
32else:
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
43if sys.version_info < (3, 12, 1):
44 from ._suppress import suppress
45else:
46 from contextlib import suppress