Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PyOV] Restrict `np.bool_` as attribute option for `create_context` and `create_tensor` (#39556)

Łukasz Ślusarczykddfd1dd9e731
diff --git a/src/bindings/python/src/pyopenvino/utils/utils.cpp b/src/bindings/python/src/pyopenvino/utils/utils.cpp
index ea69d13aeb5..6c56ce1dfe4 100644
--- a/src/bindings/python/src/pyopenvino/utils/utils.cpp
+++ b/src/bindings/python/src/pyopenvino/utils/utils.cpp
@@ -336,7 +336,11 @@ static void* to_pointer(const std::string& name, py::object value) {
if (value.is_none()) {
return nullptr;
}
- OPENVINO_ASSERT(!py::isinstance<py::bool_>(value), "The value of ", name, expected_types);
+ OPENVINO_ASSERT(
+ !py::isinstance<py::bool_>(value) && !py::isinstance(value, py::module_::import("numpy").attr("bool_")),
+ "The value of ",
+ name,
+ expected_types);
const auto index = py::reinterpret_steal<py::object>(PyNumber_Index(value.ptr()));
if (!index) {
PyErr_Clear();