[pypy-svn] r35129 - in pypy/dist/pypy: annotation/test objspace/std translator/goal

arigo at codespeak.net arigo at codespeak.net
Wed Nov 29 17:22:09 CET 2006


Author: arigo
Date: Wed Nov 29 17:22:07 2006
New Revision: 35129

Modified:
   pypy/dist/pypy/annotation/test/test_annrpython.py
   pypy/dist/pypy/objspace/std/complexobject.py
   pypy/dist/pypy/translator/goal/ann_override.py
Log:
(arre, pedronis, arigo)

Argh!  This call to newbool(float) was making all calls to newbool()
convert their argument to a float and back :-/


Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py	Wed Nov 29 17:22:07 2006
@@ -2438,6 +2438,20 @@
         assert s.const == ("42", "4")
 
 
+    def test_float_cmp(self):
+        def fun(x, y):
+            return (x < y,
+                    x <= y,
+                    x == y,
+                    x != y,
+                    x > y,
+                    x >= y)
+
+        a = self.RPythonAnnotator(policy=policy.AnnotatorPolicy())
+        s = a.build_types(fun, [float, float])
+        assert [s_item.knowntype for s_item in s.items] == [bool] * 6
+
+
 def g(n):
     return [0,1,2,n]
 

Modified: pypy/dist/pypy/objspace/std/complexobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/complexobject.py	(original)
+++ pypy/dist/pypy/objspace/std/complexobject.py	Wed Nov 29 17:22:07 2006
@@ -243,7 +243,8 @@
 
 def nonzero__Complex(space, w_complex):
     assert space.is_true(space.isinstance(w_complex, space.w_complex))
-    return space.newbool(w_complex.realval or w_complex.imagval)
+    return space.newbool((w_complex.realval != 0.0) or
+                         (w_complex.imagval != 0.0))
 
 def coerce__Complex_Complex(space, w_complex1, w_complex2):
     return space.newtuple([w_complex1, w_complex2])

Modified: pypy/dist/pypy/translator/goal/ann_override.py
==============================================================================
--- pypy/dist/pypy/translator/goal/ann_override.py	(original)
+++ pypy/dist/pypy/translator/goal/ann_override.py	Wed Nov 29 17:22:07 2006
@@ -1,11 +1,18 @@
 # overrides for annotation specific to PyPy codebase
-from pypy.annotation.policy import AnnotatorPolicy
+from pypy.annotation.policy import AnnotatorPolicy, Sig
 # for some reason, model must be imported first,
 # or we create a cycle.
 from pypy.objspace.flow.model import Constant
 from pypy.annotation import model as annmodel
 from pypy.annotation.bookkeeper import getbookkeeper
 from pypy.annotation import specialize
+from pypy.interpreter import baseobjspace
+
+
+# patch - mostly for debugging, to enfore some signatures
+baseobjspace.ObjSpace.newbool.im_func._annenforceargs_ = Sig(lambda s1,s2: s1,
+                                                             bool)
+
 
 class PyPyAnnotatorPolicy(AnnotatorPolicy):
     allow_someobjects = False



More information about the Pypy-commit mailing list