summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2022-10-30 07:07:38 -0500
committerJason Madden <jamadden@gmail.com>2022-10-30 07:07:38 -0500
commit6c47fbe9aa0ffd6379e18a8e8be0104c0542834e (patch)
tree257f029e6ca0c102667dbd315c61357e9b437965
parent865a6776253eae3116e3ab48a918a767d37db176 (diff)
downloadgreenlet-6c47fbe9aa0ffd6379e18a8e8be0104c0542834e.tar.gz
tests: narrow the scope of the catch so as not to interefere with internals.
-rw-r--r--src/greenlet/greenlet.cpp9
-rw-r--r--src/greenlet/tests/_test_extension_cpp.cpp2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/greenlet/greenlet.cpp b/src/greenlet/greenlet.cpp
index ed8acf5..9d30fa2 100644
--- a/src/greenlet/greenlet.cpp
+++ b/src/greenlet/greenlet.cpp
@@ -6,6 +6,7 @@
* Fix missing braces with:
* clang-tidy src/greenlet/greenlet.c -fix -checks="readability-braces-around-statements"
*/
+#include <cstdlib>
#include <string>
#include <algorithm>
#include <exception>
@@ -1392,9 +1393,10 @@ UserGreenlet::inner_bootstrap(OwnedGreenlet& origin_greenlet, OwnedObject& run)
// thread exits. (See comments about G_NOEXCEPT.) So this
// may not actually represent anything untoward.
# if defined(WIN32) || defined(_WIN32)
- fprintf(stderr, "greenlet: Unhandled C++ exception from a greenlet run function. ");
- fprintf(stderr, "Because memory is likely corrupted, terminating process.");
- abort();
+ Py_FatalError(
+ "greenlet: Unhandled C++ exception from a greenlet run function. "
+ "Because memory is likely corrupted, terminating process.");
+ std::abort();
#else
throw;
#endif
@@ -1453,6 +1455,7 @@ UserGreenlet::inner_bootstrap(OwnedGreenlet& origin_greenlet, OwnedObject& run)
PyErr_WriteUnraisable(this->self().borrow_o());
Py_FatalError("greenlet: ran out of parent greenlets while propagating exception; "
"cannot continue");
+ std::abort();
}
diff --git a/src/greenlet/tests/_test_extension_cpp.cpp b/src/greenlet/tests/_test_extension_cpp.cpp
index 344929d..d4dfd5e 100644
--- a/src/greenlet/tests/_test_extension_cpp.cpp
+++ b/src/greenlet/tests/_test_extension_cpp.cpp
@@ -110,7 +110,7 @@ test_exception_switch_and_do_in_g2(PyObject* self, PyObject* args)
return NULL;
}
}
- catch (...) {
+ catch (const exception_t& e) {
/* if we are here the memory can be already corrupted and the program
* might crash before below py-level exception might become printed.
* -> print something to stderr to make it clear that we had entered