Skip to content

Commit

Permalink
BUG: Fix numpy.bool check
Browse files Browse the repository at this point in the history
  • Loading branch information
seberg committed Mar 12, 2024
1 parent f0457a5 commit 247d5c3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ class type_caster<bool> {
value = false;
return true;
}
if (convert || (std::strcmp("numpy.bool_", Py_TYPE(src.ptr())->tp_name) == 0)) {
// (allow non-implicit conversion for numpy booleans)
if (convert || (std::strncmp("numpy.bool", Py_TYPE(src.ptr())->tp_name, 10) == 0)) {
// (allow non-implicit conversion for numpy booleans), use strncmp
// since NumPy 1.x had an additional trailing underscore.

Py_ssize_t res = -1;
if (src.is_none()) {
Expand Down

0 comments on commit 247d5c3

Please sign in to comment.