commit 2c6aa212d03d30b8c63160cb931afe31cc2c5876 Author: Philipp Winter phw@nymity.ch Date: Wed Feb 5 14:03:11 2020 -0800
Remove subscript notation for dict_items object.
In Python 3, a dictionary's items() method returns a dict_items rather than a list type. It's not possible to use subscript notation for a dict_items type. This patch fixes the issue, which was caught by the following unit test:
[FAIL] Traceback (most recent call last): File "/home/travis/build/NullHypothesis/bridgedb/bridgedb/test/test_main.py", line 159, in _eb_Failure self.fail(failure) twisted.trial.unittest.FailTest: [Failure instance: Traceback: <class 'TypeError'>: 'dict_items' object is not subscriptable /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/twisted/internet/base.py:1292:mainLoop /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/twisted/internet/base.py:886:runUntilCurrent /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/twisted/internet/defer.py:460:callback /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/twisted/internet/defer.py:568:_startRunCallbacks --- <exception caught here> --- /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/twisted/internet/defer.py:654:_runCallbacks /home/travis/build/NullHypothesis/bridgedb/bridgedb/test/test_main.py:153:_cbCallUpdateBridgeHistory /home/travis/build/NullHypothesis/bridgedb/bridgedb/test/test_main.py:55:mockUpdateBridgeHistory ]
bridgedb.test.test_main.BridgedbTests.test_main_updateBridgeHistory --- bridgedb/Stability.py | 2 +- bridgedb/test/test_main.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bridgedb/Stability.py b/bridgedb/Stability.py index c7bd454..34ea51d 100644 --- a/bridgedb/Stability.py +++ b/bridgedb/Stability.py @@ -278,7 +278,7 @@ def updateBridgeHistory(bridges, timestamps): logging.debug("Beginning bridge stability calculations") sortedTimestamps = {}
- for fingerprint, stamps in timestamps.items()[:]: + for fingerprint, stamps in timestamps.items(): stamps.sort() bridge = bridges[fingerprint] for timestamp in stamps: diff --git a/bridgedb/test/test_main.py b/bridgedb/test/test_main.py index 87b4a81..82b609f 100644 --- a/bridgedb/test/test_main.py +++ b/bridgedb/test/test_main.py @@ -52,7 +52,7 @@ def mockUpdateBridgeHistory(bridges, timestamps): which doesn't access the database (so that we can test functions which call it, like :func:`bridgedb.main.load`). """ - for fingerprint, stamps in timestamps.items()[:]: + for fingerprint, stamps in timestamps.items(): for timestamp in stamps: print("Pretending to update Bridge %s with timestamp %s..." % (fingerprint, timestamp))