lib.data: fix wrong class name on Struct and Union.

This commit is contained in:
Wanda 2024-03-27 08:38:22 +01:00 committed by Catherine
parent f261071f7c
commit 1d5de80347

View file

@ -1042,15 +1042,15 @@ class _AggregateMeta(ShapeCastable, type):
# be instantiated. It can also be subclassed, and used to share layout and behavior. # be instantiated. It can also be subclassed, and used to share layout and behavior.
layout = dict() layout = dict()
default = dict() default = dict()
for name in {**namespace["__annotations__"]}: for field_name in {**namespace["__annotations__"]}:
try: try:
Shape.cast(namespace["__annotations__"][name]) Shape.cast(namespace["__annotations__"][field_name])
except TypeError: except TypeError:
# Not a shape-castable annotation; leave as-is. # Not a shape-castable annotation; leave as-is.
continue continue
layout[name] = namespace["__annotations__"].pop(name) layout[field_name] = namespace["__annotations__"].pop(field_name)
if name in namespace: if field_name in namespace:
default[name] = namespace.pop(name) default[field_name] = namespace.pop(field_name)
cls = type.__new__(metacls, name, bases, namespace) cls = type.__new__(metacls, name, bases, namespace)
if cls.__layout_cls is UnionLayout: if cls.__layout_cls is UnionLayout:
if len(default) > 1: if len(default) > 1: