launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25994
[Merge] ~cjwatson/launchpad:py3-personsubscriptions-comprehension into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-personsubscriptions-comprehension into launchpad:master.
Commit message:
Fix inverted nested comprehension in PersonSubscriptions
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396189
This code:
all_tasks = [task for task in bug.bugtasks for bug in bugs]
... is roughly equivalent to:
all_tasks = []
for task in bug.bugtasks:
for bug in bugs:
all_tasks.append(task)
This clearly isn't what the author intended. We seem to get away with it somehow on Python 2 (although I'm not quite sure how; it may still cause some subtle problems), but on Python 3 it causes test failures in at least lp.bugs.browser.tests.test_bug_views.TestMainBugView. Putting the nesting the right way round fixes it.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-personsubscriptions-comprehension into launchpad:master.
diff --git a/lib/lp/bugs/model/personsubscriptioninfo.py b/lib/lp/bugs/model/personsubscriptioninfo.py
index 1d82c22..279c3a0 100644
--- a/lib/lp/bugs/model/personsubscriptioninfo.py
+++ b/lib/lp/bugs/model/personsubscriptioninfo.py
@@ -183,7 +183,7 @@ class PersonSubscriptions(object):
# Preload bug owners, then all pillars.
list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
[bug.ownerID for bug in bugs]))
- all_tasks = [task for task in bug.bugtasks for bug in bugs]
+ all_tasks = [task for bug in bugs for task in bug.bugtasks]
load_related(Product, all_tasks, ['product_id'])
load_related(Distribution, all_tasks, ['distribution_id'])
for bug in bugs: