From: Martin Willi Date: Fri, 27 Feb 2015 13:30:34 +0000 (+0100) Subject: vici: Use OrderedDict to handle vici responses in Python library X-Git-Tag: 5.3.0rc1~28^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=305023a27d97653b67510035edc95ccf26599ede;p=thirdparty%2Fstrongswan.git vici: Use OrderedDict to handle vici responses in Python library The default Python dictionaries are unordered, but order is important for some vici trees (for example the order of authentication rounds). --- diff --git a/src/libcharon/plugins/vici/python/vici/protocol.py b/src/libcharon/plugins/vici/python/vici/protocol.py index 60b94ede9e..88e1c34707 100644 --- a/src/libcharon/plugins/vici/python/vici/protocol.py +++ b/src/libcharon/plugins/vici/python/vici/protocol.py @@ -3,6 +3,7 @@ import socket import struct from collections import namedtuple +from collections import OrderedDict from .exception import DeserializationException @@ -150,13 +151,13 @@ class Message(object): "Expected end of list at {pos}".format(pos=stream.tell()) ) - section = {} + section = OrderedDict() section_stack = [] while stream.has_more(): element_type, = struct.unpack("!B", stream.read(1)) if element_type == cls.SECTION_START: section_name = decode_named_type(stream) - new_section = {} + new_section = OrderedDict() section[section_name] = new_section section_stack.append(section) section = new_section