On 20-04-29 10:25, Gerald Combs wrote:
| On 4/29/20 9:47 AM, Jaap Keuter wrote:
| > Hi list,
| >
| > While working on the IDL dissectors, so packet-coseventcomm.c,
| > packet-cosnaming.c, packet- gias.c, packet-parlay.c and
| > packet-tango.c, I was able to use the idl2wrs toolchain to
| > regenerate all these dissectors (with minor issues), with the
| > exception of packet-parlay.c. There the diff extensive and seems
| > limited to the /* User exception filters */ area. A superficial
| > look gives the impression that all items are there, that just the
| > ordering is very different. Anyone an idea why that would be?
|
| It looks like get_exceptionList in wireshark_gen.py doesn't sort the
| list it returns. According to the Python 3 documentation[1], dicts
| use insertion order in 3.7 and later, but that may or may not be the
| case in earlier versions.
|
| [1]https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects
Historically python dict key ordering wasn't deterministic (as far as
being obvious to humans :), although as you mention python 3.7 maintains
insertion order. You can use collections.OrderedDict to maintain
insertion order for older python (in python 2.7, with workarounds in
python 2.6)
As to the problem; looking at the use of .keys() in wireshark_gen.py,
there's a couple of places where the code is either:
- get_intlist(), sorted:
ret = list(ex_hash.keys())
ret.sort()
return ret
- get_exceptionList(), unsorted:
ret = list(ex_hash.keys())
return ret
Both could be simplified to an ordered result using sorted():
ret = sorted(ex_hash.keys())
return ret
Also, dumpvars() could sort its result by replacing:
for fn in self.fn_hash.keys():
with
for fn in sorted(self.fn_hash):
cheers,
Luke.