Commit a503f162 authored by Stefan Behnel's avatar Stefan Behnel

merge

parents 673e8007 01d8cb4f
...@@ -84,6 +84,9 @@ Bugs fixed ...@@ -84,6 +84,9 @@ Bugs fixed
generates a 'default' clause to avoid C compiler warnings about generates a 'default' clause to avoid C compiler warnings about
unmatched enum values. unmatched enum values.
* Fixed a bug where class hierarchies declared out-of-order could result
in broken generated code.
* Fixed a bug which prevented overriding const methods of C++ classes. * Fixed a bug which prevented overriding const methods of C++ classes.
Other changes Other changes
......
...@@ -25,6 +25,7 @@ from Code import UtilityCode ...@@ -25,6 +25,7 @@ from Code import UtilityCode
from StringEncoding import EncodedString, escape_byte_string, split_string_literal from StringEncoding import EncodedString, escape_byte_string, split_string_literal
import Options import Options
import DebugFlags import DebugFlags
from Cython.Utils import cached_function
absolute_path_length = 0 absolute_path_length = 0
...@@ -378,7 +379,25 @@ class StatListNode(Node): ...@@ -378,7 +379,25 @@ class StatListNode(Node):
def analyse_declarations(self, env): def analyse_declarations(self, env):
#print "StatListNode.analyse_declarations" ### #print "StatListNode.analyse_declarations" ###
base_classes = {}
for stat in self.stats: for stat in self.stats:
if isinstance(stat, CClassDefNode) and not stat.base_class_module:
base_classes[stat.class_name] = stat.base_class_name
@cached_function
def depth(class_name):
base_class = base_classes.get(class_name)
if class_name is None:
return 0
else:
return depth(base_class) + 1
keyed_stats = []
for ix, stat in enumerate(self.stats):
if isinstance(stat, CClassDefNode):
key = 20, depth(stat.class_name), ix
else:
key = 10, ix
keyed_stats.append((key, stat))
for key, stat in sorted(keyed_stats):
stat.analyse_declarations(env) stat.analyse_declarations(env)
def analyse_expressions(self, env): def analyse_expressions(self, env):
...@@ -2955,6 +2974,9 @@ class DefNodeWrapper(FuncDefNode): ...@@ -2955,6 +2974,9 @@ class DefNodeWrapper(FuncDefNode):
if not arg.type.is_pyobject: if not arg.type.is_pyobject:
if not arg.type.create_from_py_utility_code(env): if not arg.type.create_from_py_utility_code(env):
pass # will fail later pass # will fail later
elif arg.hdr_type and not arg.hdr_type.is_pyobject:
if not arg.hdr_type.create_to_py_utility_code(env):
pass # will fail later
def signature_has_nongeneric_args(self): def signature_has_nongeneric_args(self):
argcount = len(self.args) argcount = len(self.args)
......
cdef class B(A):
cpdef foo(self):
"""
>>> B().foo()
B
"""
print "B"
cdef class A(object):
cpdef foo(self):
"""
>>> A().foo()
A
"""
print "A"
cdef class C(A):
cpdef foo(self):
"""
>>> C().foo()
C
"""
print "C"
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