Skip to content

Commit 8356073

Browse files
committed
No, I don't have an uninitialized variable
1 parent cffc586 commit 8356073

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

include/pybind11/cast.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,17 +1044,12 @@ struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_t
10441044
return false;
10451045
} else {
10461046
handle src_or_index = src;
1047+
py_value = (py_type) -1;
10471048
#if PY_VERSION_HEX < 0x03080000
10481049
object index;
1049-
if (index_check(src.ptr())) {
1050+
if (!PYBIND11_LONG_CHECK(src.ptr()) && index_check(src.ptr())) {
10501051
index = reinterpret_steal<object>(PyNumber_Index(src.ptr()));
1051-
if (!index) {
1052-
src_or_index = handle();
1053-
py_value = (py_type) -1;
1054-
}
1055-
else {
1056-
src_or_index = index;
1057-
}
1052+
src_or_index = index ? index : handle();
10581053
}
10591054
#endif
10601055
if (src_or_index) {

0 commit comments

Comments
 (0)