[tor-commits] [stem/master] Preserve config ordering when saving

atagar at torproject.org atagar at torproject.org
Sun Dec 6 21:57:12 UTC 2015


commit 50bdfe192da3d279a5e21e6d466c189934995c7e
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Nov 29 15:59:44 2015 -0800

    Preserve config ordering when saving
    
    Saving the config contents in the order that the entries were added. This is
    important in case the caller cares about preserving ordering.
---
 stem/util/conf.py |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/stem/util/conf.py b/stem/util/conf.py
index 22cf1c7..3c97058 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -452,7 +452,7 @@ class Config(object):
 
   def __init__(self):
     self._path = None        # location we last loaded from or saved to
-    self._contents = {}      # configuration key/value pairs
+    self._contents = OrderedDict()  # configuration key/value pairs
     self._listeners = []     # functors to be notified of config changes
 
     # used for accessing _contents
@@ -549,7 +549,7 @@ class Config(object):
 
     with self._contents_lock:
       with open(self._path, 'w') as output_file:
-        for entry_key in sorted(self.keys()):
+        for entry_key in self.keys():
           for entry_value in self.get_value(entry_key, multiple = True):
             # check for multi line entries
             if '\n' in entry_value:





More information about the tor-commits mailing list