[pypy-commit] pypy default: Same issue with subclasses of 'long' or 'float'.
arigo
noreply at buildbot.pypy.org
Tue May 17 15:54:18 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r44250:f06654c419a4
Date: 2011-05-17 16:03 +0200
http://bitbucket.org/pypy/pypy/changeset/f06654c419a4/
Log: Same issue with subclasses of 'long' or 'float'.
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/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_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
More information about the pypy-commit
mailing list