[pypy-svn] r56424 - pypy/dist/pypy/module/itertools

arigo at codespeak.net arigo at codespeak.net
Thu Jul 10 18:28:17 CEST 2008


Author: arigo
Date: Thu Jul 10 18:28:15 2008
New Revision: 56424

Modified:
   pypy/dist/pypy/module/itertools/interp_itertools.py
Log:
Remove unnecessary catching.


Modified: pypy/dist/pypy/module/itertools/interp_itertools.py
==============================================================================
--- pypy/dist/pypy/module/itertools/interp_itertools.py	(original)
+++ pypy/dist/pypy/module/itertools/interp_itertools.py	Thu Jul 10 18:28:15 2008
@@ -122,11 +122,7 @@
         if self.stopped:
             raise OperationError(self.space.w_StopIteration, self.space.w_None)
 
-        try:
-            w_obj = self.space.next(self.iterable)
-        except StopIteration:
-            raise OperationError(self.space.w_StopIteration, self.space.w_None)
-
+        w_obj = self.space.next(self.iterable)  # may raise a w_StopIteration
         w_bool = self.space.call_function(self.w_predicate, w_obj)
         if not self.space.is_true(w_bool):
             self.stopped = True
@@ -169,17 +165,10 @@
 
     def next_w(self):
         if self.started:
-            try:
-                w_obj = self.space.next(self.iterable)
-            except StopIteration:
-                raise OperationError(self.space.w_StopIteration, self.space.w_None)
+            w_obj = self.space.next(self.iterable)  # may raise w_StopIteration
         else:
             while True:
-                try:
-                    w_obj = self.space.next(self.iterable)
-                except StopIteration:
-                    raise OperationError(self.space.w_StopIteration, self.space.w_None)
-
+                w_obj = self.space.next(self.iterable)  # may raise w_StopIter
                 w_bool = self.space.call_function(self.w_predicate, w_obj)
                 if not self.space.is_true(w_bool):
                     self.started = True
@@ -228,11 +217,7 @@
 
     def next_w(self):
         while True:
-            try:
-                w_obj = self.space.next(self.iterable)
-            except StopIteration:
-                raise OperationError(self.space.w_StopIteration, self.space.w_None)
-
+            w_obj = self.space.next(self.iterable)  # may raise w_StopIteration
             if self._call_predicate(w_obj):
                 return w_obj
 



More information about the Pypy-commit mailing list