[pypy-svn] r9325 - pypy/branch/dist-interpapp/pypy/interpreter

hpk at codespeak.net hpk at codespeak.net
Sat Feb 19 11:52:05 CET 2005


Author: hpk
Date: Sat Feb 19 11:52:05 2005
New Revision: 9325

Modified:
   pypy/branch/dist-interpapp/pypy/interpreter/typedef.py
Log:
improved formatting for generating the typecheck code 


Modified: pypy/branch/dist-interpapp/pypy/interpreter/typedef.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/interpreter/typedef.py	(original)
+++ pypy/branch/dist-interpapp/pypy/interpreter/typedef.py	Sat Feb 19 11:52:05 2005
@@ -123,18 +123,21 @@
         miniglobals[cls_name] = cls
         check = "isinstance(obj, %s)" % cls_name
         expected = "%s.typedef.name" % cls_name
-    
-    exec ("""def descr_typecheck_%(name)s(space, w_obj, %(extra)s):
-    obj = %(unwrap)s
-    if obj is None or not %(check)s:
-       raise OperationError(space.w_TypeError,
-                            space.wrap("descriptor is for '%%s'" %% %(expected)s)) # xxx improve
-    return %(name)s(space, obj, %(extra)s)
-""" % {'name': func.__name__, 
-       'check': check,
-       'expected': expected,
-       'unwrap': unwrap,
-       'extra': ', '.join(extraargs)}) in miniglobals
+   
+    source = """if 1: 
+        def descr_typecheck_%(name)s(space, w_obj, %(extra)s):
+            obj = %(unwrap)s
+            if obj is None or not %(check)s:
+                # xxx improve msg
+                msg =  "descriptor is for '%%s'" %% %(expected)s
+                raise OperationError(space.w_TypeError, space.wrap(msg))
+            return %(name)s(space, obj, %(extra)s)
+        \n""" % {'name': func.__name__, 
+                 'check': check,
+                 'expected': expected,
+                 'unwrap': unwrap,
+                 'extra': ', '.join(extraargs)} 
+    exec source in miniglobals 
     return miniglobals['descr_typecheck_%s' % func.__name__]    
 
 



More information about the Pypy-commit mailing list