Skip to content

Commit

Permalink
Merge pull request #1180 from Thrameos/uncaught
Browse files Browse the repository at this point in the history
Fix error in 3.12 during exception handling
  • Loading branch information
marscher authored Apr 5, 2024
2 parents 904fc43 + faaaca4 commit 543054b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion native/common/jp_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion native/python/pyjp_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 543054b

Please sign in to comment.