Kaydet (Commit) f43e9c85 authored tarafından Zack M. Davis's avatar Zack M. Davis

we should also correctly handle Python 3.5 **kwargs in class definitions

üst 62021070
......@@ -212,7 +212,10 @@ class SourceGenerator(ExplicitNodeVisitor):
# with python 2.6.
if hasattr(node, 'keywords'):
for keyword in node.keywords:
self.write(paren_or_comma, keyword.arg, '=', keyword.value)
if keyword.arg is None:
self.write(paren_or_comma, '**', keyword.value)
else:
self.write(paren_or_comma, keyword.arg, '=', keyword.value)
if sys.version_info < (3, 5):
self.conditional_write(paren_or_comma, '*', node.starargs)
self.conditional_write(paren_or_comma, '**', node.kwargs)
......
......@@ -102,6 +102,12 @@ class CodegenTestCase(unittest.TestCase):
return datum""")
self.assertAstSourceEqualIfAtLeastVersion(source, (3, 5))
def test_class_definition_with_starbases_and_kwargs(self):
source = textwrap.dedent("""\
class TreeFactory(*[FactoryMixin, TreeBase], **{'metaclass': Foo}):
pass""")
self.assertAstSourceEqualIfAtLeastVersion(source, (3, 0))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment