[tor-commits] [bridgedb/develop] Error concatenating range with a list

phw at torproject.org phw at torproject.org
Wed Feb 19 18:27:17 UTC 2020


commit f76c06102fe83417dc7c391c9c614f7fd54ff8c0
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Jan 15 17:19:08 2020 -0800

    Error concatenating range with a list
    
    BridgeDB relies on catch-alls to address its underlying buginess, which is
    making this harder. Removed one to uncover our http_server's actual
    exception...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_https_server.py", line 740, in test_renderAnswer_GET_textplain_malicious
          page = self.bridgesResource.render(request)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/https/server.py", line 920, in render
          response = self.getBridgeRequestAnswer(request)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/https/server.py", line 967, in getBridgeRequestAnswer
          bridgeRequest, self.includeFingerprints)) for bridge in bridges]
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/https/server.py", line 967, in <listcomp>
          bridgeRequest, self.includeFingerprints)) for bridge in bridges]
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/util.py", line 266, in replaceControlChars
          if byte in range(0, 32) + [92, 127]:
      builtins.TypeError: unsupported operand type(s) for +: 'range' and 'list'
    
    Test results changed as follows...
    
      before: FAILED (skips=109, failures=24, errors=220, successes=628)
      after:  FAILED (skips=109, failures=19, errors=221, successes=632)
---
 bridgedb/util.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bridgedb/util.py b/bridgedb/util.py
index eb20ce7..7b68831 100644
--- a/bridgedb/util.py
+++ b/bridgedb/util.py
@@ -263,7 +263,7 @@ def replaceControlChars(text, replacement=None, encoding="utf-8"):
     escaped = bytearray()
 
     for byte in bytearray(text, encoding):
-        if byte in range(0, 32) + [92, 127]:
+        if byte in list(range(0, 32)) + [92, 127]:
             if replacement:
                 byte = replacement
             else:





More information about the tor-commits mailing list