From 84c7d1dae67b7fdc2887188943c7cf6e8db44125 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 23 Apr 2010 15:21:52 +0200 Subject: [PATCH] sort variable entries in closure scope to get a predictable C code result --- Cython/Compiler/ParseTreeTransforms.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index adf90ad7..20b38442 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -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) -- 2.26.2