Daniel Diniz <aja...@gmail.com> added the comment:

Confirmed in trunk. Here's a copy-n-past'able testcase:


class xcomplex( complex ):
    def __new__(cls,*args,**kwargs):
        return complex.__new__(cls,*args,**kwargs)
    def __coerce__(self,other):
        t = complex.__coerce__(self,other)
        try:
            return (self,xcomplex(t[1]))
        except TypeError:
            return t
    def __add__(self,x):
        return xcomplex( complex.__add__(self,x) )
    def __radd__(self,x):
        return xcomplex( complex.__radd__(self,x) ) 

class xfloat(float):
    def __new__(cls,*args,**kwargs):
        return float.__new__(cls,*args,**kwargs)
    def __coerce__(self,other):
        t = float.__coerce__(self,other)
        try:
            return (self,float(t[1]))
        except TypeError:
            return t
    def __add__(self,x):
        return xfloat( float.__add__(self,x) )
    def __radd__(self,x):
        return xfloat( float.__radd__(self,x) )

z = 1j
xz = xcomplex(1j)
f = 1.0
xf = xfloat(1.0)

print type(z + xz)
print type(f + xf)

----------
components: +Interpreter Core -None
nosy: +ajaksu2, marketdickinson
versions: +Python 2.6, Python 2.7 -Python 2.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue3734>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to