Merge ~cjwatson/launchpad:py3-dict-iteration into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: b5188787cc001bbf9673ca41ff55c5c21c75f41b
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-dict-iteration
Merge into: launchpad:master
Diff against target: 12 lines (+1/-1)
1 file modified
lib/lp/bugs/externalbugtracker/bugzilla.py (+1/-1)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+398923@code.launchpad.net

Commit message

Avoid changing a dict while iterating over it

Description of the change

This breaks in Python 3, since dict.items() now returns a view rather than materializing a list up-front.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/externalbugtracker/bugzilla.py b/lib/lp/bugs/externalbugtracker/bugzilla.py
2index 5fa1163..7ab8ac5 100644
3--- a/lib/lp/bugs/externalbugtracker/bugzilla.py
4+++ b/lib/lp/bugs/externalbugtracker/bugzilla.py
5@@ -843,7 +843,7 @@ class BugzillaAPI(Bugzilla):
6
7 # As a sanity check, drop any comments that don't belong to the
8 # bug in remote_bug_id.
9- for comment_id, comment in comments.items():
10+ for comment_id, comment in list(comments.items()):
11 if int(comment['bug_id']) != actual_bug_id:
12 del comments[comment_id]
13

Subscribers

People subscribed via source and target branches

to status/vote changes: