[Pyrex] is this an "if" bug?
Bryan Weingarten
bryan.weingarten at pobox.com
Wed Nov 26 15:53:46 CET 2003
i don't understand why this doesn't work
cdef object callback
def play(self, callback=None):
if not callback:
self.callback = default_callback
else:
self.callback = callback
or this doesn't work
def play(self, callback=None):
self.callback = callback or default_callback
but this _does_ work:
def play(self, callback=None):
if not callback:
callback = default_callback
self.callback = callback
on the fail cases i get this error:
TypeError: 'NoneType' object is not callable
bryan
Bryan Weingarten wrote:
> is this a bug in pyrex?
>
> the following pyrex code:
> if callback:
>
>
> generates this c code. notice the if (__pyx_2 < 0). shouldn't that
> be if (__pyx_2 != 0) ? this is failing for me.
> __pyx_2 = PyObject_IsTrue(__pyx_1);
> if (__pyx_2 < 0) {
> }
>
> of course the fix is easy... just compare the if with something explicit.
>
> bryan
>
>
>
>
>
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex
>
>
More information about the Pyrex
mailing list