Skip to content

Commit ab6b69a

Browse files
committed
ClassDerivedObject: python values converted to .NET must not be disposed
1 parent b9e0f14 commit ab6b69a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/runtime/classderived.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,6 @@ public static T InvokeMethod<T>(IPythonDerivedType obj, string methodName, strin
671671
}
672672

673673
PyObject py_result = method.Invoke(pyargs);
674-
disposeList.Add(py_result);
675674
return (T)py_result.AsManagedObject(typeof(T));
676675
}
677676
}
@@ -774,12 +773,10 @@ public static T InvokeGetProperty<T>(IPythonDerivedType obj, string propertyName
774773
try
775774
{
776775
Runtime.XIncref(self.pyHandle);
777-
using (var pyself = new PyObject(self.pyHandle))
778-
using (PyObject pyvalue = pyself.GetAttr(propertyName))
779-
{
776+
using var pyself = new PyObject(self.pyHandle);
777+
PyObject pyvalue = pyself.GetAttr(propertyName);
780778
return (T)pyvalue.AsManagedObject(typeof(T));
781779
}
782-
}
783780
finally
784781
{
785782
Runtime.PyGILState_Release(gs);

0 commit comments

Comments
 (0)