@@ -31,5 +31,47 @@ def test_as_binding():
31
31
e_with_source = Exception ()
32
32
e_with_source .a = SOURCE
33
33
raise e_with_source
34
- except* Exception as e :
35
- SINK (e .a ) # $ MISSING: flow
34
+ except* Exception as eg :
35
+ SINK (eg .exceptions [0 ].a ) # $ MISSING: flow
36
+
37
+ @expects (4 )
38
+ def test_group ():
39
+ value_error_with_source = ValueError ()
40
+ value_error_with_source .a = SOURCE
41
+
42
+ type_error_without_source = TypeError ()
43
+ type_error_without_source .a = NONSOURCE
44
+
45
+ os_error_without_source = OSError ()
46
+ os_error_without_source .a = NONSOURCE
47
+
48
+ eg = ExceptionGroup (
49
+ "one" ,
50
+ [
51
+ type_error_without_source ,
52
+ ExceptionGroup (
53
+ "two" ,
54
+ [type_error_without_source , value_error_with_source ]
55
+ ),
56
+ ExceptionGroup (
57
+ "three" ,
58
+ [os_error_without_source ]
59
+ )
60
+ ]
61
+ )
62
+ try :
63
+ raise eg
64
+ except* (TypeError , OSError ) as es :
65
+ # The matched sub-group, represented by `es` is filtered,
66
+ # but the nesting is in place.
67
+ SINK_F (es .exceptions [0 ].a )
68
+ SINK_F (es .exceptions [1 ].exceptions [0 ].a )
69
+ SINK_F (es .exceptions [2 ].exceptions [0 ].a )
70
+ except* ValueError as es :
71
+ # The matched sub-group, represented by `es` is filtered,
72
+ # but the nesting is in place.
73
+ # So the ValueError was originally found in
74
+ # `eg.exceptions[1].exceptions[1].a`
75
+ # but now it is found in
76
+ # `es.exceptions[0].exceptions[0].a`
77
+ SINK (es .exceptions [0 ].exceptions [0 ].a ) # $ MISSING: flow
0 commit comments