tweak raise/dict syntax for Python 3 compat

Use the `raise` statement directly.

Switch to using .items() instead of .iteritems().  Python 3 doesn't
have .iteritems() as .items() is a generator, and these are small
enough that the Python 2 overhead should be negligible.

We have to run .keys() through list() in a few places as Python 3
uses a generator and we sometimes want to iterate more than once.
That's why we don't change all .keys() or .items() calls -- most
are in places where generators are fine.

Bug: https://crbug.com/gerrit/10418
Change-Id: I469899d9b77ffd77ccabb831bc4b217407fefe6f
This commit is contained in:
Mike Frysinger
2019-06-13 02:13:23 -04:00
parent 35159abbeb
commit 31067c0ac5
3 changed files with 8 additions and 8 deletions

View File

@ -58,7 +58,7 @@ It is equivalent to "git branch -D <branchname>".
pm.update()
if opt.all:
branches = project.GetBranches().keys()
branches = list(project.GetBranches().keys())
else:
branches = [nb]

View File

@ -99,7 +99,7 @@ class Info(PagedCommand):
self.headtext(p.revisionExpr)
self.out.nl()
localBranches = p.GetBranches().keys()
localBranches = list(p.GetBranches().keys())
self.heading("Local Branches: ")
self.redtext(str(len(localBranches)))
if len(localBranches) > 0: