Skip to content

Commit 00653dc

Browse files
committed
PythonException.StackTrace is GIL-safe
1 parent e58411d commit 00653dc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/runtime/pythonexception.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,15 @@ public void Restore()
268268
/// A string representing the python exception stack trace.
269269
/// </remarks>
270270
public override string StackTrace
271-
=> (Traceback is null ? "" : TracebackToString(Traceback))
272-
+ base.StackTrace;
271+
{
272+
get
273+
{
274+
if (Traceback is null) return base.StackTrace;
275+
276+
using var _ = new Py.GILState();
277+
return TracebackToString(Traceback) + base.StackTrace;
278+
}
279+
}
273280

274281
public override string Message => GetMessage();
275282

0 commit comments

Comments
 (0)