diff --git a/rtc_plugins.cpp b/rtc_plugins.cpp index 37acd75..af34092 100644 --- a/rtc_plugins.cpp +++ b/rtc_plugins.cpp @@ -174,6 +174,12 @@ void init_numpy() { BOOST_PYTHON_MODULE(rtc_plugins) { try { init_numpy(); + void** numpy_api = (void**)PyArray_API; + if (!numpy_api || !numpy_api[93]) { // 93是PyArray_SimpleNew的偏移量 + std::cout << "NumPy API corrupt! Key functions missing." << std::endl; + PyErr_Print(); + throw std::runtime_error("Invalid NumPy API state"); + } if (!PyArray_API) { std::cout << "PyArray_API is null" << std::endl;