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

Martin von Zweigbergk martinvonz at google.com
Thu Apr 9 20:31:52 UTC 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at 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.

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:


More information about the Mercurial-devel mailing list