Patchwork [1,of,4] manifest.walk: use return instead of StopIteration in generator

login
register
mail settings
Submitter Martin von Zweigbergk
Date April 9, 2015, 8:31 p.m.
Message ID <2823c16b36866512fd18.1428611512@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8581/
State Accepted
Headers show

Comments

Martin von Zweigbergk - April 9, 2015, 8:31 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1428471377 25200
#      Tue Apr 07 22:36:17 2015 -0700
# Node ID 2823c16b36866512fd18390cd9966e89a6936012
# Parent  33ab99a6ad9b2492af4f3c7a45736d2aac50f980
manifest.walk: use return instead of StopIteration in generator

Using "return" within a generator is supposedly more Pythonic than
raising StopIteration.

Patch

diff -r 33ab99a6ad9b -r 2823c16b3686 mercurial/manifest.py
--- a/mercurial/manifest.py	Wed Apr 08 23:30:02 2015 +0900
+++ b/mercurial/manifest.py	Tue Apr 07 22:36:17 2015 -0700
@@ -228,7 +228,7 @@ 
         if fset and not match.anypats() and util.all(fn in self for fn in fset):
             for fn in sorted(fset):
                 yield fn
-            raise StopIteration
+            return
 
         for fn in self:
             if fn in fset: