diff --git a/include/pybind11/numpy_dtypes_user.h b/include/pybind11/numpy_dtypes_user.h index 29c69e4678..44d9702f42 100644 --- a/include/pybind11/numpy_dtypes_user.h +++ b/include/pybind11/numpy_dtypes_user.h @@ -578,8 +578,10 @@ class dtype_user : public object { // recursive loops. tp_as_number.nb_float = &handle_nb_conversion; tp_as_number.nb_int = &handle_nb_conversion; +#if PY_VERSION_HEX < 0x03000000 tp_as_number.nb_long = &handle_nb_conversion; tp_as_number.nb_coerce = &disable_nb_coerce; +#endif // Create views into created type. self() = reinterpret_borrow(handle((PyObject*)&ClassObject_Type)); cls_ = self(); diff --git a/tests/test_numpy_dtypes_user.cpp b/tests/test_numpy_dtypes_user.cpp index 7776ce5a5a..6ef844698e 100644 --- a/tests/test_numpy_dtypes_user.cpp +++ b/tests/test_numpy_dtypes_user.cpp @@ -332,7 +332,7 @@ TEST_SUBMODULE(numpy_dtype_user, m) { m.def("add_one", [](py::handle in) { auto value = py::cast>(in.attr("flat")); - int count = value.size(); + int count = static_cast(value.size()); for (int i = 0; i < count; ++i) { auto& x = value.mutable_at(i); x += 1;