Backport 1.7 3806

Backport #3806: ` [fix] Check for errors in PyArray_CanCastTypeto DEPRECATE`.