[tor-commits] [bridgedb/master] Hashing requires bytes
phw at torproject.org
phw at torproject.org
Wed Feb 19 18:26:37 UTC 2020
commit cf61a322c65c533379a0bcf0f67b73cae59ec1da
Author: Damian Johnson <atagar at torproject.org>
Date: Fri Jan 17 12:28:36 2020 -0800
Hashing requires bytes
Just another instance of bytes/unicode type conversion...
Traceback (most recent call last):
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_https_distributor.py", line 153, in test_HTTPSDistributor_prepopulateRings_without_proxies
[dist.insert(bridge) for bridge in self.bridges]
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_https_distributor.py", line 153, in <listcomp>
[dist.insert(bridge) for bridge in self.bridges]
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/https/distributor.py", line 278, in insert
self.hashring.insert(bridge)
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/Bridges.py", line 606, in insert
logging.debug("Inserting %s into hashring..." % bridge)
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/bridges.py", line 1041, in __str__
fingerprint = hashlib.sha1(fingerprint).hexdigest().upper()
builtins.TypeError: Unicode-objects must be encoded before hashing
Test results changed as follows...
before: FAILED (skips=114, failures=14, errors=157, successes=700)
after: FAILED (skips=114, failures=14, errors=149, successes=708)
---
bridgedb/bridges.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bridgedb/bridges.py b/bridgedb/bridges.py
index a611c47..827a156 100644
--- a/bridgedb/bridges.py
+++ b/bridgedb/bridges.py
@@ -1037,7 +1037,7 @@ class Bridge(BridgeBackwardsCompatibility):
if safelog.safe_logging:
prefix = '$$'
if fingerprint:
- fingerprint = hashlib.sha1(fingerprint).hexdigest().upper()
+ fingerprint = hashlib.sha1(fingerprint.encode('utf-8')).hexdigest().upper()
if not fingerprint:
fingerprint = '0' * 40
More information about the tor-commits
mailing list