From f73747055d772eb21490bd8a87cbd1bf0bfc6f6a Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 25 May 2022 22:42:27 -0700 Subject: [PATCH 1/2] Replace import numpy catch (...) with catch (error_already_set) --- tests/test_numpy_array.cpp | 2 +- tests/test_numpy_dtypes.cpp | 2 +- tests/test_numpy_vectorize.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_numpy_array.cpp b/tests/test_numpy_array.cpp index 8bc77a33fa..69ddbe1ef2 100644 --- a/tests/test_numpy_array.cpp +++ b/tests/test_numpy_array.cpp @@ -162,7 +162,7 @@ static int data_i = 42; TEST_SUBMODULE(numpy_array, sm) { try { py::module_::import("numpy"); - } catch (...) { + } catch (const py::error_already_set &) { return; } diff --git a/tests/test_numpy_dtypes.cpp b/tests/test_numpy_dtypes.cpp index c25bc042b8..e28196087d 100644 --- a/tests/test_numpy_dtypes.cpp +++ b/tests/test_numpy_dtypes.cpp @@ -301,7 +301,7 @@ struct B {}; TEST_SUBMODULE(numpy_dtypes, m) { try { py::module_::import("numpy"); - } catch (...) { + } catch (py::error_already_set &) { return; } diff --git a/tests/test_numpy_vectorize.cpp b/tests/test_numpy_vectorize.cpp index eab08ec0a6..b6184ab63d 100644 --- a/tests/test_numpy_vectorize.cpp +++ b/tests/test_numpy_vectorize.cpp @@ -22,7 +22,7 @@ double my_func(int x, float y, double z) { TEST_SUBMODULE(numpy_vectorize, m) { try { py::module_::import("numpy"); - } catch (...) { + } catch (py::error_already_set &) { return; } From f91f2460f1efd1a19e7a8b85d3b151d23b6efbb7 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 25 May 2022 23:31:04 -0700 Subject: [PATCH 2/2] Add missing const (not sure how those got lost). --- tests/test_numpy_dtypes.cpp | 2 +- tests/test_numpy_vectorize.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_numpy_dtypes.cpp b/tests/test_numpy_dtypes.cpp index e28196087d..6654f9ed8f 100644 --- a/tests/test_numpy_dtypes.cpp +++ b/tests/test_numpy_dtypes.cpp @@ -301,7 +301,7 @@ struct B {}; TEST_SUBMODULE(numpy_dtypes, m) { try { py::module_::import("numpy"); - } catch (py::error_already_set &) { + } catch (const py::error_already_set &) { return; } diff --git a/tests/test_numpy_vectorize.cpp b/tests/test_numpy_vectorize.cpp index b6184ab63d..dcc4c6ac25 100644 --- a/tests/test_numpy_vectorize.cpp +++ b/tests/test_numpy_vectorize.cpp @@ -22,7 +22,7 @@ double my_func(int x, float y, double z) { TEST_SUBMODULE(numpy_vectorize, m) { try { py::module_::import("numpy"); - } catch (py::error_already_set &) { + } catch (const py::error_already_set &) { return; }