Skip to content

Commit 915423d

Browse files
committed
Ignore some tests in Python <3.8
1 parent 1380611 commit 915423d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/pybind11/cast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_t
10271027
return false;
10281028
} else if (PyFloat_Check(src.ptr())) {
10291029
return false;
1030-
} else if (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !PyIndex_Check(src.ptr())) {
1030+
} else if (!convert && !PyIndex_Check(src.ptr()) && !PYBIND11_LONG_CHECK(src.ptr())) {
10311031
return false;
10321032
} else if (std::is_unsigned<py_type>::value) {
10331033
py_value = as_unsigned<py_type>(src.ptr());

tests/test_builtin_casters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ def cant_convert(v):
289289
require_implicit(DeepThought())
290290
cant_convert(ShallowThought())
291291
cant_convert(FuzzyThought())
292-
if not env.PY2:
293-
# I have no clue why __index__ is not picked up by Python 2's PyIndex_check
292+
if env.PY >= (3, 8):
293+
# Before Python 3.8, `int(obj)` does not pick up on `obj.__index__`
294294
assert convert(IndexedThought()) == 42
295295
assert noconvert(IndexedThought()) == 42
296296
cant_convert(RaisingThought()) # no fall-back to `__int__`if `__index__` raises

0 commit comments

Comments
 (0)