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

[tor-commits] [bridgedb/develop] Replace dict's iteritems with items



commit a7bb3fbab43ca01455e283d29a3f68cbb9a0a2fe
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Jan 17 13:58:14 2020 -0800

    Replace dict's iteritems with items
    
    Python's methods for keys, values, and items now provide iterators so there is
    no longer a separate iteritems method. This fixes...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_metrics.py", line 108, in test_export
          metrics.export(pseudo_fh, 0)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/metrics.py", line 131, in export
          httpsLines = httpsMetrix.getMetrics()
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/metrics.py", line 235, in getMetrics
          for key, value in self.coldMetrics.iteritems():
      builtins.AttributeError: 'dict' object has no attribute 'iteritems'
    
    This changes test results as follows...
    
      before: FAILED (skips=114, failures=15, errors=111, successes=745)
      after:  FAILED (skips=114, failures=15, errors=109, successes=747)
---
 bridgedb/Bridges.py | 2 +-
 bridgedb/metrics.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bridgedb/Bridges.py b/bridgedb/Bridges.py
index 46b7afe..93d0190 100644
--- a/bridgedb/Bridges.py
+++ b/bridgedb/Bridges.py
@@ -539,7 +539,7 @@ class BridgeSplitter(object):
             logging.info("Current rings: %s" % " ".join(self.ringsByName))
 
     def dumpAssignments(self, f, description=""):
-        for name,ring in self.ringsByName.iteritems():
+        for name,ring in self.ringsByName.items():
             ring.dumpAssignments(f, "%s %s" % (description, name))
 
 
diff --git a/bridgedb/metrics.py b/bridgedb/metrics.py
index 5d8bda3..2785874 100644
--- a/bridgedb/metrics.py
+++ b/bridgedb/metrics.py
@@ -232,7 +232,7 @@ class Metrics(metaclass=Singleton):
         :returns: A list of metric lines.
         """
         lines = []
-        for key, value in self.coldMetrics.iteritems():
+        for key, value in self.coldMetrics.items():
             # Round up our value to the nearest multiple of self.binSize to
             # reduce the accuracy of our real values.
             if (value % self.binSize) > 0:



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