This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: adapt to zip returning an iterator
ClosedPublic

Authored by thopre on Sep 20 2019, 1:38 AM.

Details

Summary

zip() returns a list in Python 2 but an iterator in Python 3.
Fortunately, the only use is in the return statement in pairs() and the
only call site of pairs() iterates over the result. This commit thus
adds a docstrings for pairs to make it clear callers can only rely on
the result being iterable. It also rename the parameter to not conflict
with the list builtin function.

Event Timeline

thopre created this revision.Sep 20 2019, 1:38 AM
lnt/server/reporting/analysis.py
375 ↗(On Diff #220977)

The unpacking works without this change even in Python 3.

lnt/tests/nt.py
793 ↗(On Diff #220977)

I believe this change is unnecessary. The constructor will fully visit the result of zip.

thopre abandoned this revision.Sep 23 2019, 5:33 AM
thopre marked 2 inline comments as done.

Cancelling this patch since all users of zip are fine with iterable (pairs is only used in dailyreport.py in a foreach statement).

thopre reclaimed this revision.Sep 23 2019, 5:47 AM
thopre updated this revision to Diff 221310.Sep 23 2019, 5:47 AM

Add comments to pairs() stating it returns an iterable.

thopre retitled this revision from [LNT] Python 3 support: adapt to zip returning a view to [LNT] Python 3 support: adapt to zip returning an iterator.Sep 23 2019, 2:58 PM
thopre edited the summary of this revision. (Show Details)

LGTM with suggestion to update commit message.

lnt/server/reporting/report.py
11

I agree that a rename would help. Please update the commit message with the rationale.

This revision is now accepted and ready to land.Sep 24 2019, 8:48 PM
thopre edited the summary of this revision. (Show Details)Sep 25 2019, 1:24 AM
thopre closed this revision.Sep 25 2019, 1:25 AM