[pypy-commit] pypy default: bools are also floats

alex_gaynor noreply at buildbot.pypy.org
Sat Mar 23 18:39:44 CET 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r62695:2b95d7427cbd
Date: 2013-03-23 10:39 -0700
http://bitbucket.org/pypy/pypy/changeset/2b95d7427cbd/

Log:	bools are also floats

diff --git a/pypy/objspace/std/boolobject.py b/pypy/objspace/std/boolobject.py
--- a/pypy/objspace/std/boolobject.py
+++ b/pypy/objspace/std/boolobject.py
@@ -10,28 +10,31 @@
     from pypy.objspace.std.booltype import bool_typedef as typedef
     _immutable_fields_ = ['boolval']
 
-    def __init__(w_self, boolval):
-        w_self.boolval = not not boolval
+    def __init__(self, boolval):
+        self.boolval = not not boolval
 
-    def __nonzero__(w_self):
-        raise Exception, "you cannot do that, you must use space.is_true()"
+    def __nonzero__(self):
+        raise Exception("you cannot do that, you must use space.is_true()")
 
-    def __repr__(w_self):
+    def __repr__(self):
         """ representation for debugging purposes """
-        return "%s(%s)" % (w_self.__class__.__name__, w_self.boolval)
+        return "%s(%s)" % (self.__class__.__name__, self.boolval)
 
-    def unwrap(w_self, space):
-        return w_self.boolval
+    def unwrap(self, space):
+        return self.boolval
 
-    def int_w(w_self, space):
-        return int(w_self.boolval)
+    def int_w(self, space):
+        return int(self.boolval)
 
-    def uint_w(w_self, space):
-        intval = int(w_self.boolval)
+    def uint_w(self, space):
+        intval = int(self.boolval)
         return r_uint(intval)
 
-    def bigint_w(w_self, space):
-        return rbigint.fromint(int(w_self.boolval))
+    def bigint_w(self, space):
+        return rbigint.fromint(int(self.boolval))
+
+    def float_w(self, space):
+        return float(self.boolval)
 
 
 registerimplementation(W_BoolObject)


More information about the pypy-commit mailing list