[pypy-svn] r73348 - in pypy/trunk/pypy/annotation: . test

benjamin at codespeak.net benjamin at codespeak.net
Sun Apr 4 05:43:33 CEST 2010


Author: benjamin
Date: Sun Apr  4 05:43:31 2010
New Revision: 73348

Modified:
   pypy/trunk/pypy/annotation/description.py
   pypy/trunk/pypy/annotation/test/test_annrpython.py
Log:
propogate method constantness to bound methods

Modified: pypy/trunk/pypy/annotation/description.py
==============================================================================
--- pypy/trunk/pypy/annotation/description.py	(original)
+++ pypy/trunk/pypy/annotation/description.py	Sun Apr  4 05:43:31 2010
@@ -293,7 +293,8 @@
         return self.bookkeeper.getmethoddesc(self, 
                                              classdef,   # originclassdef,
                                              None,       # selfclassdef
-                                             name)
+                                             name,
+                                             pyobj=self.pyobj)
 
     def consider_call_site(bookkeeper, family, descs, args, s_result):
         shape = rawshape(args)
@@ -727,7 +728,8 @@
                                              self.originclassdef,
                                              newselfclassdef,
                                              self.name,
-                                             flags)
+                                             flags,
+                                             self.pyobj)
 
     def consider_call_site(bookkeeper, family, descs, args, s_result):
         shape = rawshape(args, nextra=1)     # account for the extra 'self'

Modified: pypy/trunk/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/trunk/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/trunk/pypy/annotation/test/test_annrpython.py	Sun Apr  4 05:43:31 2010
@@ -1768,6 +1768,22 @@
         s = a.build_types(f, [str])
         assert s == annmodel.SomeString()
 
+    def test_more_complex_method_hasattr(self):
+        class X:
+            def m(self):
+                return 4
+            m.attr = 32
+        def f():
+            x = X()
+            if hasattr(x.m, "attr"):
+                return 3
+            return 0
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [])
+        s_res = annmodel.SomeInteger(True)
+        s_res.const = 3
+        assert s == s_res
+
     def test_dont_see_AttributeError_clause(self):
         class Stuff:
             def _freeze_(self):



More information about the Pypy-commit mailing list