Commit f66909db authored by Vitja Makarov's avatar Vitja Makarov

Noargs super() support for cdef classes

parent e37ac1ed
......@@ -2424,11 +2424,11 @@ class TransformBuiltinMethods(EnvTransform):
return node
# Inject no-args super
def_node = self.current_scope_node()
if (not isinstance(def_node, Nodes.DefNode) or
if (not isinstance(def_node, Nodes.DefNode) or not def_node.args or
len(self.env_stack) < 2):
return node
class_node, class_scope = self.env_stack[-2]
if class_scope.is_py_class_scope and def_node.args:
if class_scope.is_py_class_scope:
def_node.requires_classobj = True
class_node.class_cell.is_active = True
node.args = [
......@@ -2436,7 +2436,13 @@ class TransformBuiltinMethods(EnvTransform):
node.pos, is_generator=def_node.is_generator),
ExprNodes.NameNode(node.pos, name=def_node.args[0].name)
]
return node
elif class_scope.is_c_class_scope:
node.args = [
ExprNodes.NameNode(
node.pos, name=class_node.scope.name,
entry=class_node.entry),
ExprNodes.NameNode(node.pos, name=def_node.args[0].name)
]
return node
def visit_SimpleCallNode(self, node):
......
......@@ -59,3 +59,17 @@ def test_class_cell_empty():
class EmptyClassCell(metaclass=Base):
def foo(self):
super()
cdef class CClassBase(object):
def method(self):
return 1
cdef class CClassSuper(CClassBase):
"""
>>> CClassSuper().method()
1
"""
def method(self):
return super().method()
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