From 8f5590cb9fab063d75e15fe2ea4f787b5b124659 Mon Sep 17 00:00:00 2001 From: Karl Nelson Date: Sun, 31 Mar 2024 13:02:06 -0700 Subject: [PATCH] Fix error in 3.12 during Pytest --- doc/CHANGELOG.rst | 1 + native/python/pyjp_object.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/CHANGELOG.rst b/doc/CHANGELOG.rst index 74451c308..5848e7d66 100644 --- a/doc/CHANGELOG.rst +++ b/doc/CHANGELOG.rst @@ -6,6 +6,7 @@ This changelog *only* contains changes from the *first* pypi release (0.5.4.3) o Latest Changes: - **1.5.1_dev0 - 2023-12-15** + - Fixed uncaught exception while setting traceback causing issues in Python 3.11/3.12. - Use PEP-518 and PEP-660 configuration for the package, allowing editable and configurable builds using modern Python packaging tooling. Where before ``python setup.py --enable-tracing develop``, now can be done with diff --git a/native/python/pyjp_object.cpp b/native/python/pyjp_object.cpp index 0de9f9f2c..c059eb376 100644 --- a/native/python/pyjp_object.cpp +++ b/native/python/pyjp_object.cpp @@ -390,7 +390,8 @@ void PyJPException_normalize(JPJavaFrame frame, JPPyObject exc, jthrowable th, j { // Attach the frame to first JPPyObject trace = PyTrace_FromJavaException(frame, th, enclosing); - PyException_SetTraceback(exc.get(), trace.get()); + if (trace.get()!=nullptr) + PyException_SetTraceback(exc.get(), trace.get()); // Check for the next in the cause list enclosing = th;