Skip to content

Commit

Permalink
Fix cdef class ordering in the presence of pxi includes.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwb committed Jan 14, 2014
1 parent e5642d0 commit 27a95b9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Cython/Compiler/Nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,20 @@ def create_analysed(pos, env, *args, **kw):
def analyse_declarations(self, env):
#print "StatListNode.analyse_declarations" ###
base_classes = {}
for stat in self.stats:
def flatten(stats):
# Common case is trivial flatten.
if not [stat for stat in stats if isinstance(stat, StatListNode)]:
return stats
else:
all = []
for stat in stats:
if isinstance(stat, StatListNode):
all.extend(flatten(stat.stats))
else:
all.append(stat)
return all
flattened = flatten(self.stats)
for stat in flattened:
if isinstance(stat, CClassDefNode) and not stat.base_class_module:
base_classes[stat.class_name] = stat.base_class_name
@cached_function
Expand All @@ -391,7 +404,7 @@ def depth(class_name):
else:
return depth(base_class) + 1
keyed_stats = []
for ix, stat in enumerate(self.stats):
for ix, stat in enumerate(flattened):
if isinstance(stat, CClassDefNode):
key = 20, depth(stat.class_name), ix
else:
Expand Down

0 comments on commit 27a95b9

Please sign in to comment.