[pypy-svn] r28120 - pypy/dist/pypy/objspace/std

ale at codespeak.net ale at codespeak.net
Fri Jun 2 19:20:38 CEST 2006


Author: ale
Date: Fri Jun  2 19:20:37 2006
New Revision: 28120

Modified:
   pypy/dist/pypy/objspace/std/complexobject.py
Log:
Add __int__ and __float__ to ComplexObject

Modified: pypy/dist/pypy/objspace/std/complexobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/complexobject.py	(original)
+++ pypy/dist/pypy/objspace/std/complexobject.py	Fri Jun  2 19:20:37 2006
@@ -249,6 +249,11 @@
 def coerce__Complex_Complex(space, w_complex1, w_complex2):
     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))"))
+
+int__Complex = float__Complex
+
 def complex_conjugate__Complex(space, w_self):
     #w_real = space.call_function(space.w_float,space.wrap(w_self.realval))
     #w_imag = space.call_function(space.w_float,space.wrap(-w_self.imagval))



More information about the Pypy-commit mailing list