[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/develop] Fix debug hexify statement



commit 442e38c2cd5f077592aa9fea19d8a62276b14f3f
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Jan 17 13:22:46 2020 -0800

    Fix debug hexify statement
    
    Oops, missed that there was other instances of hex conversion...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_https_distributor.py", line 235, in test_HTTPSDistributor_getBridges_with_some_blocked_bridges
          bridges = dist.getBridges(clientRequest1, 1)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/https/distributor.py", line 327, in getBridges
          logging.debug("Assigned client to subhashring position: %s" % position.encode('hex'))
      builtins.AttributeError: 'bytes' object has no attribute 'encode'
    
    Test results changed as follows...
    
      before: FAILED (skips=114, failures=15, errors=133, successes=723)
      after:  FAILED (skips=114, failures=15, errors=122, successes=734)
---
 bridgedb/Bridges.py                        | 3 ++-
 bridgedb/distributors/https/distributor.py | 3 ++-
 bridgedb/test/test_crypto.py               | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/bridgedb/Bridges.py b/bridgedb/Bridges.py
index 135174c..46b7afe 100644
--- a/bridgedb/Bridges.py
+++ b/bridgedb/Bridges.py
@@ -10,6 +10,7 @@
 them into hashrings for distributors.
 """
 
+import binascii
 import bisect
 import logging
 import re
@@ -329,7 +330,7 @@ class BridgeRing(object):
             else:
                 logging.debug(
                     "Got duplicate bridge %r in main hashring for position %r."
-                    % (logSafely(k.encode('hex')), pos.encode('hex')))
+                    % (logSafely(binascii.hexlify(k).decode('utf-8')), binascii.hexlify(pos).decode('utf-8')))
         keys.sort()
 
         if filterBySubnet:
diff --git a/bridgedb/distributors/https/distributor.py b/bridgedb/distributors/https/distributor.py
index 03aa970..f3e2e9b 100644
--- a/bridgedb/distributors/https/distributor.py
+++ b/bridgedb/distributors/https/distributor.py
@@ -20,6 +20,7 @@ A Distributor that hands out bridges through a web interface.
     :parts: 1
 """
 
+import binascii
 import ipaddr
 import logging
 
@@ -324,7 +325,7 @@ class HTTPSDistributor(Distributor):
 
         logging.debug("Client request within time interval: %s" % interval)
         logging.debug("Assigned client to subhashring %d/%d" % (subring, self.totalSubrings))
-        logging.debug("Assigned client to subhashring position: %s" % position.encode('hex'))
+        logging.debug("Assigned client to subhashring position: %s" % binascii.hexlify(position).decode('utf-8'))
         logging.debug("Total bridges: %d" % len(self.hashring))
         logging.debug("Bridge filters: %s" % ' '.join([x.__name__ for x in filters]))
 
diff --git a/bridgedb/test/test_crypto.py b/bridgedb/test/test_crypto.py
index 000ca0f..9255c30 100644
--- a/bridgedb/test/test_crypto.py
+++ b/bridgedb/test/test_crypto.py
@@ -15,6 +15,7 @@ from __future__ import print_function
 from __future__ import unicode_literals
 
 import base64
+import binascii
 import io
 import logging
 import math
@@ -87,7 +88,7 @@ class GetKeyTests(unittest.TestCase):
                          """The example key and the one read from file differ!
                          key (in hex): %s
                          SEKRIT_KEY (in hex): %s"""
-                         % (key.encode('hex'), SEKRIT_KEY.encode('hex')))
+                         % (binascii.hexlify(key).decode('utf-8'), binascii.hexlify(SEKRIT_KEY).decode('utf-8')))
 
 
 class InitializeGnuPGTests(unittest.TestCase):



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