Skip to content

Commit

Permalink
[fix] Check for errors in PyArray_CanCastTypeto DEPRECATE
Browse files Browse the repository at this point in the history
If a user had set warnings to raise errors, then this DEPRECATE would
leave us with an unpropagated exception and cause havoc downstream.

Unfortunately there is no way to propagate an exception from here, so
we just have to throw it away :-(. But this is still better than the
alternative...

Conflicts:
	numpy/core/tests/test_ufunc.py
  • Loading branch information
njsmith authored and charris committed Sep 27, 2013
1 parent 31eb6ce commit 25de8c5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions numpy/core/src/multiarray/convert_datatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,13 @@ PyArray_CanCastTypeTo(PyArray_Descr *from, PyArray_Descr *to,
same_kind_ok = PyArray_CanCastTypeTo_impl(from, to,
NPY_SAME_KIND_CASTING);
if (unsafe_ok && !same_kind_ok) {
DEPRECATE("Implicitly casting between incompatible kinds. In "
"a future numpy release, this will raise an error. "
"Use casting=\"unsafe\" if this is intentional.");
if (DEPRECATE("Implicitly casting between incompatible kinds. In "
"a future numpy release, this will raise an error. "
"Use casting=\"unsafe\" if this is intentional.")
< 0) {
/* We have no way to propagate an exception :-( */
PyErr_Clear();
}
}
return unsafe_ok;
}
Expand Down

0 comments on commit 25de8c5

Please sign in to comment.