Luca Dall'Olio, 26.09.2012 10:24: > I just converted some cython code using the "@cython.returns(a_type)" > annotation and it works like a charm, thanks for that! :-)
It was mostly an oversight that it hasn't been available for so long. The pure Python mode is still incomplete and gradually improving, mostly because the core developers do not use it much themselves and rarely notice what's missing. So it's always worth a) bringing up issues (as you did here, thanks!) and b) coming up with proposals and patches to make it more widely usable. We warmly welcome any contributions. > I was wondering how to convert in pure python mode the error return value > "except" clause ( > http://docs.cython.org/src/userguide/language_basics.html#error-return-values) > > : > > cdef int spam() except -1: > ... > > @cython.cfunc > @cython.returns(cython.int) > def spam(): > ... > > Is there any way to specify that -1 is the error return value in pure > python mode ? No, not as for as I can tell. I think it would be worth adding that to the 'returns' annotation, e.g. @cython.returns(cython.int, on_error="-1") for "except -1". Similarly: @cython.returns(cython.int, on_error="-1", check=True) for "except? -1" and @cython.returns(cython.int, on_error="+") @cython.returns(cython.void, on_error="*") for "except +" and "except *" respectively. OTOH, maybe "except *" could actually be the default in pure Python mode? Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel