[pypy-svn] pypy default: A bit of an ugly hack so that faked functions can work at interp-level and become bound as methods.

alex_gaynor commits-noreply at bitbucket.org
Wed Jan 19 20:42:08 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r40954:fb1dc83e25af
Date: 2011-01-19 13:40 -0600
http://bitbucket.org/pypy/pypy/changeset/fb1dc83e25af/

Log:	A bit of an ugly hack so that faked functions can work at interp-
	level and become bound as methods.

diff --git a/pypy/objspace/std/fake.py b/pypy/objspace/std/fake.py
--- a/pypy/objspace/std/fake.py
+++ b/pypy/objspace/std/fake.py
@@ -1,3 +1,5 @@
+import types
+
 from pypy.interpreter.error import OperationError, debug_print
 from pypy.interpreter import baseobjspace
 from pypy.interpreter import eval
@@ -121,6 +123,9 @@
             return w_self.space.wrap(d)
         def unwrap(w_self, space):
             return w_self.val
+        if cpy_type is types.FunctionType:
+            def __get__(self, obj, owner):
+                return fake_object(self.space, self.val.__get__(obj, owner))
     W_Fake.__name__ = 'W_Fake%s'%(cpy_type.__name__.capitalize())
     W_Fake.typedef.fakedcpytype = cpy_type
     return W_Fake


More information about the Pypy-commit mailing list