[tor-commits] [oonib/master] Fix: old code could raise a KeyError because choices[c] preceded the if c in choices
art at torproject.org
art at torproject.org
Wed Apr 23 14:31:51 UTC 2014
commit 3cb4394c9c4e8d20fd1068bbd0c75ab907999fdf
Author: Darius Bacon <darius at wry.me>
Date: Fri Mar 28 11:08:41 2014 -0700
Fix: old code could raise a KeyError because choices[c] preceded the if c in choices
---
oonib/bouncer/handlers.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/oonib/bouncer/handlers.py b/oonib/bouncer/handlers.py
index 47fee26..0ff103e 100644
--- a/oonib/bouncer/handlers.py
+++ b/oonib/bouncer/handlers.py
@@ -95,14 +95,13 @@ class Bouncer(object):
choices = self.getHelperAddresses(helper_name)
for item in response.values():
c = item['collector']
- h = choices[c]
- if c in choices.keys():
+ if c in choices:
break
# Or default to a random selection
else:
- c,h = random.choice(choices.items())
+ c = random.choice(choices)
- response[helper_name] = {'collector': c, 'address': h}
+ response[helper_name] = {'collector': c, 'address': choices[c]}
except e.TestHelperNotFound:
response = {'error': 'test-helper-not-found'}
More information about the tor-commits
mailing list