Skip to content

Commit 69619ce

Browse files
committed
Use extract_node instead of direct class construction
1 parent 863177d commit 69619ce

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

astroid/protocols.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from typing import TYPE_CHECKING, Any, TypeVar
1616

1717
from astroid import bases, decorators, nodes, util
18+
from astroid.builder import extract_node
1819
from astroid.const import Context
1920
from astroid.context import InferenceContext, copy_context
2021
from astroid.exceptions import (
@@ -535,15 +536,13 @@ def _generate_assigned():
535536
yield assigned
536537

537538
if isinstance(self.parent, node_classes.TryStar):
538-
# except * handler has assigned ExceptionGroup
539-
eg = nodes.ClassDef(
540-
"ExceptionGroup",
541-
self.lineno,
542-
self.col_offset,
543-
self,
544-
end_lineno=self.end_lineno,
545-
end_col_offset=self.end_col_offset,
546-
)
539+
# except * handler has assigned ExceptionGroup with caught
540+
# exceptions under exceptions attribute
541+
eg = next(node_classes.unpack_infer(
542+
extract_node('''
543+
from builtins import ExceptionGroup
544+
ExceptionGroup
545+
''')))
547546
assigned = objects.ExceptionInstance(eg)
548547
assigned.instance_attrs["exceptions"] = [
549548
nodes.List.from_elements(_generate_assigned())

0 commit comments

Comments
 (0)