[pypy-svn] r28124 - in pypy/dist/pypy/objspace/std: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Jun 3 00:00:49 CEST 2006


Author: cfbolz
Date: Sat Jun  3 00:00:47 2006
New Revision: 28124

Modified:
   pypy/dist/pypy/objspace/std/complexobject.py
   pypy/dist/pypy/objspace/std/test/test_complexobject.py
Log:
slightly more precise error message + test


Modified: pypy/dist/pypy/objspace/std/complexobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/complexobject.py	(original)
+++ pypy/dist/pypy/objspace/std/complexobject.py	Sat Jun  3 00:00:47 2006
@@ -250,9 +250,10 @@
     return space.newtuple([w_complex1, w_complex2])
 
 def float__Complex(space, w_complex):
-    raise OperationError(space.w_TypeError, space.wrap("can't convert complex to int; use int(abs(z))"))
+    raise OperationError(space.w_TypeError, space.wrap("can't convert complex to float; use abs(z)"))
 
-int__Complex = float__Complex
+def int__Complex(space, w_complex):
+    raise OperationError(space.w_TypeError, space.wrap("can't convert complex to int; use int(abs(z))"))
 
 def complex_conjugate__Complex(space, w_self):
     #w_real = space.call_function(space.w_float,space.wrap(w_self.realval))

Modified: pypy/dist/pypy/objspace/std/test/test_complexobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_complexobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_complexobject.py	Sat Jun  3 00:00:47 2006
@@ -329,3 +329,7 @@
                 os.remove(pth)
             except (OSError, IOError):
                 pass
+
+    def test_convert(self):
+        raises(TypeError, int, 1+1j)
+        raises(TypeError, float, 1+1j)



More information about the Pypy-commit mailing list