Skip to content

Commit 8d14e66

Browse files
authored
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).
1 parent 2c549eb commit 8d14e66

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

tests/test_numpy_array.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static int data_i = 42;
162162
TEST_SUBMODULE(numpy_array, sm) {
163163
try {
164164
py::module_::import("numpy");
165-
} catch (...) {
165+
} catch (const py::error_already_set &) {
166166
return;
167167
}
168168

tests/test_numpy_dtypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct B {};
301301
TEST_SUBMODULE(numpy_dtypes, m) {
302302
try {
303303
py::module_::import("numpy");
304-
} catch (...) {
304+
} catch (const py::error_already_set &) {
305305
return;
306306
}
307307

tests/test_numpy_vectorize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ double my_func(int x, float y, double z) {
2222
TEST_SUBMODULE(numpy_vectorize, m) {
2323
try {
2424
py::module_::import("numpy");
25-
} catch (...) {
25+
} catch (const py::error_already_set &) {
2626
return;
2727
}
2828

0 commit comments

Comments
 (0)