提交 f544f23e authored 作者: notoraptor's avatar notoraptor

Fix cname resolution in EnumList.

上级 3f5ed4bc
...@@ -1165,7 +1165,7 @@ class EnumList(EnumType): ...@@ -1165,7 +1165,7 @@ class EnumList(EnumType):
assert len(kwargs) in (0, 1, 2), (type(self).__name__ + assert len(kwargs) in (0, 1, 2), (type(self).__name__ +
': expected 0 to 2 extra parameters ("ctype", "cname").') ': expected 0 to 2 extra parameters ("ctype", "cname").')
ctype = kwargs.pop('ctype', 'int') ctype = kwargs.pop('ctype', 'int')
cname = kwargs.pop('cname', ctype) cname = kwargs.pop('cname', None)
for arg_rank, arg in enumerate(args): for arg_rank, arg in enumerate(args):
if isinstance(arg, (list, tuple)): if isinstance(arg, (list, tuple)):
...@@ -1187,7 +1187,9 @@ class EnumList(EnumType): ...@@ -1187,7 +1187,9 @@ class EnumList(EnumType):
raise TypeError('%s: constant name already used ("%s").' % (type(self).__name__, constant_name)) raise TypeError('%s: constant name already used ("%s").' % (type(self).__name__, constant_name))
kwargs[constant_name] = constant_value kwargs[constant_name] = constant_value
kwargs.update(ctype=ctype, cname=cname) kwargs.update(ctype=ctype)
if cname is not None:
kwargs.update(cname=cname)
super(EnumList, self).__init__(**kwargs) super(EnumList, self).__init__(**kwargs)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论