Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8045b5f

Browse files
committed
do not attempt to deallocate GCHandle of Python derived type instance from finalizer when it is not allocated (could have been cleared)
1 parentab6b69a commit8045b5f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/runtime/classderived.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ internal static Type CreateDerivedType(string name,
257257
Type.EmptyTypes);
258258
ILGeneratoril=methodBuilder.GetILGenerator();
259259
il.Emit(OpCodes.Ldarg_0);
260-
il.Emit(OpCodes.Call,typeof(PythonDerivedType).GetMethod("Finalize"));
260+
il.Emit(OpCodes.Call,typeof(PythonDerivedType).GetMethod(nameof(PythonDerivedType.Finalize)));
261261
il.Emit(OpCodes.Ldarg_0);
262262
il.Emit(OpCodes.Call,baseClass.GetMethod("Finalize",BindingFlags.NonPublic|BindingFlags.Instance));
263263
il.Emit(OpCodes.Ret);
@@ -775,8 +775,8 @@ public static T InvokeGetProperty<T>(IPythonDerivedType obj, string propertyName
775775
Runtime.XIncref(self.pyHandle);
776776
usingvarpyself=newPyObject(self.pyHandle);
777777
PyObjectpyvalue=pyself.GetAttr(propertyName);
778-
return(T)pyvalue.AsManagedObject(typeof(T));
779-
}
778+
return(T)pyvalue.AsManagedObject(typeof(T));
779+
}
780780
finally
781781
{
782782
Runtime.PyGILState_Release(gs);
@@ -886,7 +886,7 @@ public static void Finalize(IPythonDerivedType obj)
886886
Runtime.XDecref(dict);
887887
}
888888
Runtime.PyObject_GC_Del(self.pyHandle);
889-
self.gcHandle.Free();
889+
if(self.gcHandle.IsAllocated)self.gcHandle.Free();
890890
}
891891
finally
892892
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp