File tree 1 file changed +13
-9
lines changed
1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -1049,18 +1049,22 @@ struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_t
1049
1049
if (index_check (src.ptr ())) {
1050
1050
index = reinterpret_steal<object>(PyNumber_Index (src.ptr ()));
1051
1051
if (!index ) {
1052
- PyErr_Clear ();
1053
- return false ;
1052
+ src_or_index = handle ();
1053
+ py_value = (py_type) -1 ;
1054
+ }
1055
+ else {
1056
+ src_or_index = index ;
1054
1057
}
1055
- src_or_index = index ;
1056
1058
}
1057
1059
#endif
1058
- if (std::is_unsigned<py_type>::value) {
1059
- py_value = as_unsigned<py_type>(src_or_index.ptr ());
1060
- } else { // signed integer:
1061
- py_value = sizeof (T) <= sizeof (long )
1062
- ? (py_type) PyLong_AsLong (src_or_index.ptr ())
1063
- : (py_type) PYBIND11_LONG_AS_LONGLONG (src_or_index.ptr ());
1060
+ if (src_or_index) {
1061
+ if (std::is_unsigned<py_type>::value) {
1062
+ py_value = as_unsigned<py_type>(src_or_index.ptr ());
1063
+ } else { // signed integer:
1064
+ py_value = sizeof (T) <= sizeof (long )
1065
+ ? (py_type) PyLong_AsLong (src_or_index.ptr ())
1066
+ : (py_type) PYBIND11_LONG_AS_LONGLONG (src_or_index.ptr ());
1067
+ }
1064
1068
}
1065
1069
}
1066
1070
You can’t perform that action at this time.
0 commit comments