From 23ac66ef42b408e8bea92cdd15600c3681994af9 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Sat, 26 Mar 2016 13:49:37 +0000 Subject: [PATCH] Fix inconsistent emission of ``Enumerations.cs``. The ordering of emitted enum values is not consistent between python 2 or 3. The root cause of the problem was a dictionary's keys being iterated over which has no defined order. This has been fixed by iterating over the dictionary's items and ordering by values. We could order by key rather than the values but seeing as these represent an enum, ordering by value makes more sense. --- scripts/mk_genfile_common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mk_genfile_common.py b/scripts/mk_genfile_common.py index 9c6431248..0734d52b0 100644 --- a/scripts/mk_genfile_common.py +++ b/scripts/mk_genfile_common.py @@ -234,9 +234,9 @@ def mk_z3consts_dotnet_internal(api_files, output_dir): z3consts.write(' /// %s\n' % name) z3consts.write(' public enum %s {\n' % name) z3consts.write - for k in decls: - i = decls[k] - z3consts.write(' %s = %s,\n' % (k, i)) + # Iterate over key-value pairs ordered by value + for k, v in sorted(decls.items(), key=lambda pair: pair[1]): + z3consts.write(' %s = %s,\n' % (k, v)) z3consts.write(' }\n\n') mode = SEARCHING elif len(words) <= 2: