File size: 453 Bytes
60f5111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import traceback

def g(v):
    try:
        raise ValueError(v)
    except Exception as e:
        return e

def f():
    raise ExceptionGroup("eg", [g(1), g(2)])

try:
    f()
except BaseException as e:
    eg = e

for (i, (exc, tbs)) in enumerate(leaf_generator(eg)):
    print(f"\n=== Exception #{i+1}:")
    traceback.print_exception(exc)
    print(f"The complete traceback for Exception #{i+1}:")
    for tb in tbs:
        traceback.print_tb(tb)