[pypy-svn] r17541 - in pypy/dist/pypy/rpython: . test

pedronis at codespeak.net pedronis at codespeak.net
Tue Sep 13 20:11:24 CEST 2005


Author: pedronis
Date: Tue Sep 13 20:11:22 2005
New Revision: 17541

Modified:
   pypy/dist/pypy/rpython/rbuiltin.py
   pypy/dist/pypy/rpython/test/test_rdict.py
Log:
convert_const for builtin methods



Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/rbuiltin.py	Tue Sep 13 20:11:22 2005
@@ -71,6 +71,9 @@
         # methods of a known name are implemented as just their 'self'
         self.lowleveltype = self.self_repr.lowleveltype
 
+    def convert_const(self, obj):
+        return self.self_repr.convert_const(obj.__self__)
+
     def rtype_simple_call(self, hop):
         # methods: look up the rtype_method_xxx()
         name = 'rtype_method_' + self.methodname

Modified: pypy/dist/pypy/rpython/test/test_rdict.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rdict.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rdict.py	Tue Sep 13 20:11:22 2005
@@ -411,3 +411,18 @@
         return len(d) + d[a] + d[b]
     res = interpret(f, [])
     assert res == 12
+
+def test_captured_get():
+    get = {1:2}.get
+    def f():
+        return get(1, 3)+get(2, 4)
+    res = interpret(f, [])
+    assert res == 6
+
+    def g(h):
+        return h(1, 3)
+    def f():
+        return g(get)
+
+    res = interpret(f, [])
+    assert res == 2    



More information about the Pypy-commit mailing list