fix: avoid `catch (...)` for expected `import numpy` failures (#3974)

* Replace import numpy catch (...) with catch (error_already_set)

* Add missing const (not sure how those got lost).
This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-05-26 08:07:40 -07:00 committed by GitHub
parent 2c549eb7aa
commit 8d14e666e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -162,7 +162,7 @@ static int data_i = 42;
TEST_SUBMODULE(numpy_array, sm) { TEST_SUBMODULE(numpy_array, sm) {
try { try {
py::module_::import("numpy"); py::module_::import("numpy");
} catch (...) { } catch (const py::error_already_set &) {
return; return;
} }

View File

@ -301,7 +301,7 @@ struct B {};
TEST_SUBMODULE(numpy_dtypes, m) { TEST_SUBMODULE(numpy_dtypes, m) {
try { try {
py::module_::import("numpy"); py::module_::import("numpy");
} catch (...) { } catch (const py::error_already_set &) {
return; return;
} }

View File

@ -22,7 +22,7 @@ double my_func(int x, float y, double z) {
TEST_SUBMODULE(numpy_vectorize, m) { TEST_SUBMODULE(numpy_vectorize, m) {
try { try {
py::module_::import("numpy"); py::module_::import("numpy");
} catch (...) { } catch (const py::error_already_set &) {
return; return;
} }