Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 534b145

Browse files
author
Barton Cline
committed
# Apply Alexey's Exception memory leak patch #
# Apply Alexey's PythonException AquireLock patch #
1 parent dc7614d commit 534b145

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pythonnet/src/runtime/exceptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ public static void SetError(Exception e) {
473473
IntPtr etype = Runtime.PyObject_GetAttrString(op, "__class__");
474474
Runtime.PyErr_SetObject(etype, op);
475475
Runtime.Decref(etype);
476+
Runtime.Decref(op);
476477
}
477478

478479
/// <summary>

pythonnet/src/runtime/pythonexception.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public class PythonException : System.Exception {
2727

2828
public PythonException() : base()
2929
{
30+
IntPtr gs = PythonEngine.AcquireLock();
3031
Runtime.PyErr_Fetch(ref _pyType, ref _pyValue, ref _pyTB);
3132
Runtime.Incref(_pyType);
3233
Runtime.Incref(_pyValue);
3334
Runtime.Incref(_pyTB);
34-
IntPtr gs = PythonEngine.AcquireLock();
3535
if ((_pyType != IntPtr.Zero) && (_pyValue != IntPtr.Zero))
3636
{
3737
string type = new PyObject(_pyType).GetAttr("__name__").ToString();

0 commit comments

Comments
 (0)