[tor-commits] [bridgedb/develop] Replace has_key method call

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


commit adc0f16639e9f61c06c7d0d49c51199c115488c6
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Jan 17 13:18:18 2020 -0800

    Replace has_key method call
    
    Python's has_key method was always pointless since "x in my_dict" does the
    same. The method was removed in python 3 so this fixes...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_https_distributor.py", line 255, in test_HTTPSDistributor_getBridges_with_varied_blocked_bridges
          bridge.setBlockedIn('cn', methodname='vanilla')
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/bridges.py", line 1501, in setBlockedIn
          self._addBlockByKey(key, countryCode)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/bridges.py", line 1381, in _addBlockByKey
          if self._blockedIn.has_key(key):
      builtins.AttributeError: 'dict' object has no attribute 'has_key'
    
    Test results changed as follows...
    
      before: FAILED (skips=114, failures=15, errors=140, successes=716)
      after:  FAILED (skips=114, failures=15, errors=133, successes=723)
---
 bridgedb/bridges.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bridgedb/bridges.py b/bridgedb/bridges.py
index 827a156..cdd1ae8 100644
--- a/bridgedb/bridges.py
+++ b/bridgedb/bridges.py
@@ -1377,7 +1377,7 @@ class Bridge(BridgeBackwardsCompatibility):
             :meth:`_getBlockKey`.
         :param str countryCode: A two-character country code specifier.
         """
-        if self._blockedIn.has_key(key):
+        if key in self._blockedIn:
             self._blockedIn[key].append(countryCode.lower())
         else:
             self._blockedIn[key] = [countryCode.lower(),]





More information about the tor-commits mailing list