Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 543054b

Browse files
authoredApr 5, 2024··
Merge pull request #1180 from Thrameos/uncaught
Fix error in 3.12 during exception handling
2 parents 904fc43 + faaaca4 commit 543054b

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed
 

‎doc/CHANGELOG.rst

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This changelog *only* contains changes from the *first* pypi release (0.5.4.3) o
66
Latest Changes:
77

88
- **1.5.1_dev0 - 2023-12-15**
9+
- Fixed uncaught exception while setting traceback causing issues in Python 3.11/3.12.
910
- Use PEP-518 and PEP-660 configuration for the package, allowing editable and
1011
configurable builds using modern Python packaging tooling.
1112
Where before ``python setup.py --enable-tracing develop``, now can be done with

‎native/common/jp_exception.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ void JPypeException::convertJavaToPython()
220220
PyJPException_normalize(frame, prev, jcause, th);
221221
PyException_SetCause(cause.get(), prev.keep());
222222
}
223-
PyException_SetTraceback(cause.get(), trace.get());
223+
if (trace.get() != nullptr)
224+
PyException_SetTraceback(cause.get(), trace.get());
224225
PyException_SetCause(pyvalue.get(), cause.keep());
225226
} catch (JPypeException& ex)
226227
{

‎native/python/pyjp_object.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ void PyJPException_normalize(JPJavaFrame frame, JPPyObject exc, jthrowable th, j
390390
{
391391
// Attach the frame to first
392392
JPPyObject trace = PyTrace_FromJavaException(frame, th, enclosing);
393-
PyException_SetTraceback(exc.get(), trace.get());
393+
if (trace.get() != nullptr)
394+
PyException_SetTraceback(exc.get(), trace.get());
394395

395396
// Check for the next in the cause list
396397
enclosing = th;

0 commit comments

Comments
 (0)
Please sign in to comment.