mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-12 17:26:13 +00:00
Move PyErr_NormalizeException() up a few lines (#3971)
* Add error_already_set_what what tests, asserting the status quo.
* Move PyErr_NormalizeException() up a few lines.
* @pytest.mark.skipif("env.PYPY") from PR #1895 is required even for this much simpler PR
* Move PyException_SetTraceback() with PyErr_NormalizeException() as suggested by @skylion007
* Insert a std::move() as suggested by @skylion007
This commit is contained in:
committed by
GitHub
parent
2d4a20c8cb
commit
2c549eb7aa
@@ -478,6 +478,11 @@ PYBIND11_NOINLINE std::string error_string() {
|
||||
|
||||
error_scope scope; // Preserve error state
|
||||
|
||||
PyErr_NormalizeException(&scope.type, &scope.value, &scope.trace);
|
||||
if (scope.trace != nullptr) {
|
||||
PyException_SetTraceback(scope.value, scope.trace);
|
||||
}
|
||||
|
||||
std::string errorString;
|
||||
if (scope.type) {
|
||||
errorString += handle(scope.type).attr("__name__").cast<std::string>();
|
||||
@@ -487,12 +492,6 @@ PYBIND11_NOINLINE std::string error_string() {
|
||||
errorString += (std::string) str(scope.value);
|
||||
}
|
||||
|
||||
PyErr_NormalizeException(&scope.type, &scope.value, &scope.trace);
|
||||
|
||||
if (scope.trace != nullptr) {
|
||||
PyException_SetTraceback(scope.value, scope.trace);
|
||||
}
|
||||
|
||||
#if !defined(PYPY_VERSION)
|
||||
if (scope.trace) {
|
||||
auto *trace = (PyTracebackObject *) scope.trace;
|
||||
|
||||
Reference in New Issue
Block a user