llvm-project
4440e87b - [mlir:python] Fix crash in from_python in type casters. (#191764)

Commit
8 days ago
[mlir:python] Fix crash in from_python in type casters. (#191764) This PR fixes a crash due to a failed assertion in the `from_python` implementations of the type casters. The assertion obviously only triggers if assertions are enabled, which isn't the case for many Python installations, *and* if a Python capsule of the wrong type is attempted to be used, so this this isn't triggered easily. The problem is that the conversion from Python capsules may set the Python error indicator but the callers of the type casters do not expect that. In fact, if there are several operloads of a function, the first may cause the error indicator to be set and the second runs into the assertion. The fix is to unset the error indicator after a failed capsule conversion, which is indicated with the return value of the function anyways. In alternative fix would be to unset the error indicator *inside* the `mlirPythonCapsuleTo*` functions; however, their documentations does say that the Python error indicator is set, so I assume that some callers may *want* to see the indicator and that the responsibility to handle it is on them. Signed-off-by: Ingo Müller <ingomueller@google.com>
Parents
Loading