mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-04 13:29:11 +00:00 
			
		
		
		
	Fix inconsistent emission of `z3consts.py`. 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.
This commit is contained in:
		
							parent
							
								
									a2376b1016
								
							
						
					
					
						commit
						75af362b25
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -105,9 +105,9 @@ def mk_z3consts_py_internal(api_files, output_dir):
 | 
				
			||||||
                if m:
 | 
					                if m:
 | 
				
			||||||
                    name = words[1]
 | 
					                    name = words[1]
 | 
				
			||||||
                    z3consts.write('# enum %s\n' % name)
 | 
					                    z3consts.write('# enum %s\n' % name)
 | 
				
			||||||
                    for k in decls:
 | 
					                    # Iterate over key-value pairs ordered by value
 | 
				
			||||||
                        i = decls[k]
 | 
					                    for k, v in sorted(decls.items(), key=lambda pair: pair[1]):
 | 
				
			||||||
                        z3consts.write('%s = %s\n' % (k, i))
 | 
					                        z3consts.write('%s = %s\n' % (k, v))
 | 
				
			||||||
                    z3consts.write('\n')
 | 
					                    z3consts.write('\n')
 | 
				
			||||||
                    mode = SEARCHING
 | 
					                    mode = SEARCHING
 | 
				
			||||||
                elif len(words) <= 2:
 | 
					                elif len(words) <= 2:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue