You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is something I'm running into while trying to sort out implicit exception_value for fused types. But it's a general problem not related to fused functions.
Essentially for floating point types, Cython uses a number of different representations of the exception value, and this leads to mismatches where there should be no mismatch
Code to reproduce the behaviour:
cdef double return_double(double arg, bint fail):
if fail:
raiseRuntimeErrorreturn arg
ctypedef double (*func_ptr1)(double, bint) except? -1deftest():
# Test that we can assign to the function pointer we expect
cdef func_ptr1 p1 = return_double
This fails with
Error compiling Cython file:
------------------------------------------------------------
...
ctypedef double (*func_ptr1)(double, bint) except? -1
def test():
# Test that we can assign to the function pointer we expect
cdef func_ptr1 p1 = return_double
^
------------------------------------------------------------
fused_rettype3.pyx:10:24: Cannot assign type 'double (double, bool) except? -1' to 'func_ptr1'. Exception values are incompatible.
The reason is that the type for return_double has an exception_value of '-1' (note a str).
The type for func_ptr1 has an exception_value of '-1.0' (note also a str).
Therefore they're "incompatible" and the assignment fails.
Expected behaviour
No response
OS
No response
Python version
No response
Cython version
Current master
Additional context
I think the mistake is using strings to represent exception_value
The text was updated successfully, but these errors were encountered:
I think the mistake is using strings to represent exception_value
Not entirely a mistake. You can have an exception value that is an enum name, for example. So, if we start using numeric values, we'll still have to deal with strings, but then in combination with different numeric data types.
Describe the bug
This is something I'm running into while trying to sort out implicit exception_value for fused types. But it's a general problem not related to fused functions.
Essentially for floating point types, Cython uses a number of different representations of the exception value, and this leads to mismatches where there should be no mismatch
Code to reproduce the behaviour:
This fails with
The reason is that the type for
return_double
has anexception_value
of'-1'
(note astr
).The type for
func_ptr1
has anexception_value
of'-1.0'
(note also astr
).Therefore they're "incompatible" and the assignment fails.
Expected behaviour
No response
OS
No response
Python version
No response
Cython version
Current master
Additional context
I think the mistake is using strings to represent
exception_value
The text was updated successfully, but these errors were encountered: