f2py issue when returning a single tuple #2981

rgommers opened this Issue Feb 12, 2013 · 0 comments


None yet

1 participant

NumPy member

From http://projects.scipy.org/scipy/ticket/1187, comment of Pearu:

f2py supports user-defined functions that have multiple return values. These return values are expected to be returned as a single tuple object. So, the issue here is not a result of f2py bug but due to this f2py feature that is unintentionally triggered by the given example.

As a possible fix, we could have the f2py code to treat the returned tuples as ordinary sequences when the expected number of returned values is exactly 1. On the other hand, in the case of f2py misuse (returning 2 values when 1 is expected, for instance) the values will be silently converted to an array and may result even a more complicated issues to be analyzed.

I think the best fix is to document this f2py feature in the corresponding codes, that is, never return tuple as a single return value, and perhaps improve the error message giving a hint why the crash might have been occurred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment