commit cf61a322c65c533379a0bcf0f67b73cae59ec1da
Author: Damian Johnson <ata...@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



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to