[pypy-svn] pypy default: Fix complex.__getnewargs__; unskip an old test
amauryfa
commits-noreply at bitbucket.org
Thu Jan 27 01:53:35 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r41375:65ccbcc673fd
Date: 2011-01-27 01:10 +0100
http://bitbucket.org/pypy/pypy/changeset/65ccbcc673fd/
Log: Fix complex.__getnewargs__; unskip an old test
diff --git a/pypy/objspace/std/test/test_complexobject.py b/pypy/objspace/std/test/test_complexobject.py
--- a/pypy/objspace/std/test/test_complexobject.py
+++ b/pypy/objspace/std/test/test_complexobject.py
@@ -10,10 +10,10 @@
class TestW_ComplexObject:
- def _test_instantiation(self):
+ def test_instantiation(self):
def _t_complex(r=0.0,i=0.0):
c = W_ComplexObject(r, i)
- assert c.real == float(r) and c.imag == float(i)
+ assert c.realval == float(r) and c.imagval == float(i)
pairs = (
(1, 1),
(1.0, 2.0),
@@ -430,3 +430,6 @@
def __complex__(self):
return None
raises(TypeError, complex, complex2(1j))
+
+ def test_getnewargs(self):
+ assert (1+2j).__getnewargs__() == (1.0, 2.0)
diff --git a/pypy/objspace/std/complextype.py b/pypy/objspace/std/complextype.py
--- a/pypy/objspace/std/complextype.py
+++ b/pypy/objspace/std/complextype.py
@@ -215,7 +215,8 @@
def descr___getnewargs__(space, w_self):
from pypy.objspace.std.complexobject import W_ComplexObject
assert isinstance(w_self, W_ComplexObject)
- return space.newtuple([space.newcomplex(w_self.realval,w_self.imagval)])
+ return space.newtuple([space.newfloat(w_self.realval),
+ space.newfloat(w_self.imagval)])
complex_typedef = StdTypeDef("complex",
__doc__ = """complex(real[, imag]) -> complex number
More information about the Pypy-commit
mailing list