commit fd4b1bbaeea1791cf69bbbfdd89ce7bc6e111088 Author: Damian Johnson atagar@torproject.org Date: Fri Jan 17 12:47:39 2020 -0800
Fix hex conversion
Replacing hex encoding with a python 3 equivalent...
Python 2:
>>> 'hello'.encode('hex') '68656c6c6f'
Python 3:
>>> import binascii >>> binascii.hexlify('hello'.encode('utf-8')) b'68656c6c6f'
This fixes...
Traceback (most recent call last): File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_https_distributor.py", line 154, in test_HTTPSDistributor_prepopulateRings_without_proxies dist.prepopulateRings() File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/https/distributor.py", line 254, in prepopulateRings filters = self._buildHashringFilters([filterFn,], subring) File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/https/distributor.py", line 281, in _buildHashringFilters f = bySubring(self.hashring.hmac, subring, self.totalSubrings) File "/home/atagar/Desktop/tor/bridgedb/bridgedb/filters.py", line 46, in bySubring name = "-".join([str(hmac("")[:8]).encode('hex'), builtins.LookupError: 'hex' is not a text encoding; use codecs.encode() to handle arbitrary codecs
Test results changed as follows...
before: FAILED (skips=114, failures=14, errors=149, successes=708) after: FAILED (skips=114, failures=14, errors=143, successes=714) --- bridgedb/filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bridgedb/filters.py b/bridgedb/filters.py index 78cb73e..3ea0723 100644 --- a/bridgedb/filters.py +++ b/bridgedb/filters.py @@ -13,6 +13,7 @@
"""Functions for filtering :class:`Bridges <bridgedb.bridges.Bridge>`."""
+import binascii import logging
from ipaddr import IPv4Address @@ -43,7 +44,7 @@ def bySubring(hmac, assigned, total): logging.debug(("Creating a filter for assigning bridges to subhashring " "%s-of-%s...") % (assigned, total))
- name = "-".join([str(hmac("")[:8]).encode('hex'), + name = "-".join([binascii.hexlify(str(hmac("")[:8]).encode('utf-8')).decode('utf-8'), str(assigned), "of", str(total)]) try: return _cache[name]
tor-commits@lists.torproject.org