commit 2ebd329ff3c9079828d62529e1e01be9ba0cdf1d Author: Damian Johnson atagar@torproject.org Date: Sat Jun 7 10:55:53 2014 -0700
Python 2.6 broken by OrderedDict usage
In our recent release I swapped our stem.util.conf to use an OrderedDict, breaking our support for python 2.6...
% python2.6 ./run_tests.py --unit Traceback (most recent call last): File "./run_tests.py", line 465, in <module> main() File "./run_tests.py", line 119, in main test_config.load(os.path.join(STEM_BASE, "test", "settings.cfg")) File "/home/atagar/Desktop/stem/stem/util/conf.py", line 504, in load self.set(key, value, False) File "/home/atagar/Desktop/stem/stem/util/conf.py", line 604, in set listener(self, key) File "/home/atagar/Desktop/stem/stem/util/conf.py", line 175, in update new_value = config.get(key, self.config_dict[key]) File "/home/atagar/Desktop/stem/stem/util/conf.py", line 685, in get valMap = collections.OrderedDict() AttributeError: 'module' object has no attribute 'OrderedDict'
Caught by pmezard on...
https://trac.torproject.org/12223
This is actually something we've already dealt with elsewhere. Stem contains its own python 2.6 compatable copy of the OrderedDict module, I just forgot to use it here. --- stem/util/conf.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/stem/util/conf.py b/stem/util/conf.py index 7c1cd69..6443fba 100644 --- a/stem/util/conf.py +++ b/stem/util/conf.py @@ -157,11 +157,16 @@ Here's an expanation of what happened... +- get_value - provides the value for a given key as a string """
-import collections import threading
from stem.util import log
+try: + # added in python 2.7 + from collections import OrderedDict +except ImportError: + from stem.util.ordereddict import OrderedDict + CONFS = {} # mapping of identifier to singleton instances of configs
@@ -682,7 +687,7 @@ class Config(object): elif isinstance(default, tuple): val = tuple(val) elif isinstance(default, dict): - valMap = collections.OrderedDict() + valMap = OrderedDict() for entry in val: if '=>' in entry: entryKey, entryVal = entry.split('=>', 1)