File tree 2 files changed +7
-0
lines changed
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -1173,6 +1173,9 @@ template <> class type_caster<bool> {
1173
1173
value = (bool ) res;
1174
1174
return true ;
1175
1175
}
1176
+ else {
1177
+ PyErr_Clear ();
1178
+ }
1176
1179
}
1177
1180
return false ;
1178
1181
}
Original file line number Diff line number Diff line change @@ -318,11 +318,15 @@ def test_numpy_bool():
318
318
import numpy as np
319
319
convert , noconvert = m .bool_passthrough , m .bool_passthrough_noconvert
320
320
321
+ def cant_convert (v ):
322
+ pytest .raises (TypeError , convert , v )
323
+
321
324
# np.bool_ is not considered implicit
322
325
assert convert (np .bool_ (True )) is True
323
326
assert convert (np .bool_ (False )) is False
324
327
assert noconvert (np .bool_ (True )) is True
325
328
assert noconvert (np .bool_ (False )) is False
329
+ cant_convert (np .zeros (2 , dtype = 'int' ))
326
330
327
331
328
332
def test_int_long ():
You can’t perform that action at this time.
0 commit comments