[Numpy-discussion] NotImplementedType should be an exception

Charles R Harris charlesr.harris@gmail....
Sat Jun 21 13:01:24 CDT 2008


On Sat, Jun 21, 2008 at 8:57 AM, Charles R Harris <charlesr.harris@gmail.com>
wrote:

>
>
> On Sat, Jun 21, 2008 at 7:39 AM, Travis E. Oliphant <
> oliphant@enthought.com> wrote:
>
>> Charles R Harris wrote:
>> > Shouldn't this raise an NotImplementedError exception?
>> >
>> > In [7]: type(remainder(complex192(1), complex192(1)))
>> > Out[7]: <type 'NotImplementedType'>
>> I'm not sure if it is relevant in this case but we do need to keep in
>> mind that Python uses the NotImplementedType as a signal to hand off the
>> calculation to the other object in a binary operation.
>>
>> If we change this here we may affect that behavior, unintentionally.
>>
>
> But Python only does that if the Py_TPFLAGS_CHECKTYPES bit in the tp_flag
> is set. With that flag it should try with the other variable, then raise a
> Type error if that fails also. That's why I think the flag isn't set for
> these variables; we should never see the NotImplementedType. And at first
> glance at the code, I don't think that flag *is* set for the type.
>

This particular return comes from ufunc_generic_call and I'm not sure what
Python should or can do in this case. Thoughts?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080621/e8545b4c/attachment.html 


More information about the Numpy-discussion mailing list