[pypy-svn] r56592 - pypy/branch/2.5-features/pypy/interpreter

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Jul 16 16:15:31 CEST 2008


Author: cfbolz
Date: Wed Jul 16 16:15:29 2008
New Revision: 56592

Modified:
   pypy/branch/2.5-features/pypy/interpreter/generator.py
Log:
A small tweak: use NoneNotWrapped as a default value to get real Nones.


Modified: pypy/branch/2.5-features/pypy/interpreter/generator.py
==============================================================================
--- pypy/branch/2.5-features/pypy/interpreter/generator.py	(original)
+++ pypy/branch/2.5-features/pypy/interpreter/generator.py	Wed Jul 16 16:15:29 2008
@@ -1,5 +1,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.gateway import NoneNotWrapped
 
 
 class GeneratorIterator(Wrappable):
@@ -64,22 +65,16 @@
             self.frame.f_back = None
             self.running = False
 
-    def descr_throw(self, w_type, w_val=None, w_tb=None):
+    def descr_throw(self, w_type, w_val=None, w_tb=NoneNotWrapped):
         """throw(typ[,val[,tb]]) -> raise exception in generator,
 return next yielded value or raise StopIteration."""
         return self.throw(w_type, w_val, w_tb)
 
 
-    def throw(self, w_type, w_val=None, w_tb=None):
+    def throw(self, w_type, w_val, w_tb):
         from pypy.interpreter.typedef import PyTraceback
         space = self.space
        
-        if space.is_w(w_tb, space.w_None):
-            w_tb = None
-
-        if w_val is None:
-            w_val = space.w_None
-
         if w_tb is not None:
             if not space.is_true(space.isinstance(w_tb, 
                     space.gettypeobject(PyTraceback.typedef))):
@@ -119,7 +114,7 @@
         """close(arg) -> raise GeneratorExit inside generator."""
         space = self.space
         try:
-            w_retval = self.throw(space.w_GeneratorExit)
+            w_retval = self.throw(space.w_GeneratorExit, space.w_None, None)
         except OperationError, e:
             if e.match(space, space.w_StopIteration) or \
                     e.match(space, space.w_GeneratorExit):



More information about the Pypy-commit mailing list