Author: Maciej Fijalkowski <fij...@gmail.com>
Branch: 
Changeset: r44252:6d32191a0ae3
Date: 2011-05-17 16:53 +0200
http://bitbucket.org/pypy/pypy/changeset/6d32191a0ae3/

Log:    merge heads

diff --git a/pypy/objspace/std/floattype.py b/pypy/objspace/std/floattype.py
--- a/pypy/objspace/std/floattype.py
+++ b/pypy/objspace/std/floattype.py
@@ -264,7 +264,7 @@
     return space.call_function(w_cls, w_float)
 
 def descr_get_real(space, w_obj):
-    return w_obj
+    return space.float(w_obj)
 
 def descr_get_imag(space, w_obj):
     return space.wrap(0.0)
diff --git a/pypy/objspace/std/inttype.py b/pypy/objspace/std/inttype.py
--- a/pypy/objspace/std/inttype.py
+++ b/pypy/objspace/std/inttype.py
@@ -179,7 +179,7 @@
     return space.wrap(1)
 
 def descr_get_real(space, w_obj):
-    return w_obj
+    return space.int(w_obj)
 
 def descr_get_imag(space, w_obj):
     return space.wrap(0)
diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py
--- a/pypy/objspace/std/longtype.py
+++ b/pypy/objspace/std/longtype.py
@@ -104,7 +104,7 @@
     return space.newlong(1)
 
 def descr_get_real(space, w_obj):
-    return w_obj
+    return space.long(w_obj)
 
 def descr_get_imag(space, w_obj):
     return space.newlong(0)
diff --git a/pypy/objspace/std/test/test_floatobject.py 
b/pypy/objspace/std/test/test_floatobject.py
--- a/pypy/objspace/std/test/test_floatobject.py
+++ b/pypy/objspace/std/test/test_floatobject.py
@@ -417,6 +417,11 @@
         f = 1.1234e200
         assert f.__format__("G") == "1.1234E+200"
 
+    def test_float_real(self):
+        class A(float): pass
+        b = A(5).real
+        assert type(b) is float
+
 
 class AppTestFloatHex:
     def w_identical(self, x, y):
diff --git a/pypy/objspace/std/test/test_intobject.py 
b/pypy/objspace/std/test/test_intobject.py
--- a/pypy/objspace/std/test/test_intobject.py
+++ b/pypy/objspace/std/test/test_intobject.py
@@ -480,6 +480,11 @@
         ]:
             assert val.bit_length() == bits
 
+    def test_int_real(self):
+        class A(int): pass
+        b = A(5).real
+        assert type(b) is int
+
 
 class AppTestIntOptimizedAdd(AppTestInt):
     def setup_class(cls):
diff --git a/pypy/objspace/std/test/test_longobject.py 
b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -323,3 +323,7 @@
         assert type(as_long) is long
         assert as_long == 64
 
+    def test_long_real(self):
+        class A(long): pass
+        b = A(5).real
+        assert type(b) is long
diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py
--- a/pypy/translator/c/funcgen.py
+++ b/pypy/translator/c/funcgen.py
@@ -705,7 +705,7 @@
         offset = self.expr(op.args[2])
         value = self.expr(op.args[3])
         typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '')
-        return "*(((%(typename)s) %(addr)s ) + %(offset)s) = %(value)s;" % 
locals()
+        return "((%(typename)s) %(addr)s)[%(offset)s] = %(value)s;" % locals()
 
     def OP_RAW_LOAD(self, op):
         addr = self.expr(op.args[0])
@@ -713,7 +713,7 @@
         offset = self.expr(op.args[2])
         result = self.expr(op.result)
         typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '')
-        return "%(result)s = *(((%(typename)s) %(addr)s ) + %(offset)s);" % 
locals()
+        return "%(result)s = ((%(typename)s) %(addr)s)[%(offset)s];" % locals()
 
     def OP_CAST_PRIMITIVE(self, op):
         TYPE = self.lltypemap(op.result)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to