sort variable entries in closure scope to get a predictable C code result
authorStefan Behnel <scoder@users.berlios.de>
Fri, 23 Apr 2010 13:21:52 +0000 (15:21 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 23 Apr 2010 13:21:52 +0000 (15:21 +0200)
Cython/Compiler/ParseTreeTransforms.py

index adf90ad76b98c360ef10038c57eeb72c068373fc..20b384429dcfc65f7ca5d99f145fe487052806f8 100644 (file)
@@ -1228,17 +1228,18 @@ class CreateClosureClasses(CythonTransform):
                                     cname=Naming.outer_scope_cname,
                                     type=node.entry.scope.scope_class.type,
                                     is_cdef=True)
-        for entry in func_scope.entries.values():
+        entries = func_scope.entries.items()
+        entries.sort()
+        for name, entry in entries:
             # This is wasteful--we should do this later when we know
             # which vars are actually being used inside...
             #
             # Also, this happens before type inference and type
             # analysis, so the entries created here may end up having
             # incorrect or at least unspecified types.
-            cname = entry.cname
             class_scope.declare_var(pos=entry.pos,
                                     name=entry.name,
-                                    cname=cname,
+                                    cname=entry.cname,
                                     type=entry.type,
                                     is_cdef=True)