From faaaca428dd906a84b259250042e22ff6a6a7df7 Mon Sep 17 00:00:00 2001 From: Karl Nelson Date: Mon, 1 Apr 2024 17:04:14 -0700 Subject: [PATCH] Fix second uncaught exception --- native/common/jp_exception.cpp | 3 ++- native/python/pyjp_object.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/native/common/jp_exception.cpp b/native/common/jp_exception.cpp index 10cc9c9ec..a99964c69 100644 --- a/native/common/jp_exception.cpp +++ b/native/common/jp_exception.cpp @@ -220,7 +220,8 @@ void JPypeException::convertJavaToPython() PyJPException_normalize(frame, prev, jcause, th); PyException_SetCause(cause.get(), prev.keep()); } - PyException_SetTraceback(cause.get(), trace.get()); + if (trace.get() != nullptr) + PyException_SetTraceback(cause.get(), trace.get()); PyException_SetCause(pyvalue.get(), cause.keep()); } catch (JPypeException& ex) { diff --git a/native/python/pyjp_object.cpp b/native/python/pyjp_object.cpp index c059eb376..ae2ffbe0d 100644 --- a/native/python/pyjp_object.cpp +++ b/native/python/pyjp_object.cpp @@ -390,7 +390,7 @@ void PyJPException_normalize(JPJavaFrame frame, JPPyObject exc, jthrowable th, j { // Attach the frame to first JPPyObject trace = PyTrace_FromJavaException(frame, th, enclosing); - if (trace.get()!=nullptr) + if (trace.get() != nullptr) PyException_SetTraceback(exc.get(), trace.get()); // Check for the next in the cause list