[pypy-svn] rev 480 - pypy/trunk/src/pypy/objspace

alex at codespeak.net alex at codespeak.net
Mon May 26 19:31:05 CEST 2003


Author: alex
Date: Mon May 26 19:31:05 2003
New Revision: 480

Modified:
   pypy/trunk/src/pypy/objspace/trivial.py
Log:
fixing newfunction


Modified: pypy/trunk/src/pypy/objspace/trivial.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/trivial.py	(original)
+++ pypy/trunk/src/pypy/objspace/trivial.py	Mon May 26 19:31:05 2003
@@ -170,9 +170,13 @@
             raise NoValue
 
     def newfunction(self, code, globals, defaultarguments, closure=None):
-        if closure is None:   # temp hack for Python 2.2
-            return new.function(code, globals, None, defaultarguments)
-        return new.function(code, globals, None, defaultarguments, closure)
+        def newfun(self, *args, **kwds):
+            locals = code.build_arguments(self, args, kwds,
+                w_defaults = defaultarguments,
+                w_closure = closure)
+            return code.evalcode(self, globals, locals)
+        newfun.__name__ = code.co_name
+        return newfun
 
     def newstring(self, asciilist):
         return ''.join([chr(ascii) for ascii in asciilist])


More information about the Pypy-commit mailing list