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
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commit38b3f01

Browse files
committed
classderived: handle tp_dealloc called after tp_clear
Because tp_clear sets tpHandle to NULL, it can't be used.Fortunately, we can simply read object's type from pyHandle.
1 parent9682dc6 commit38b3f01

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎src/runtime/classderived.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ internal ClassDerivedObject(Type tp) : base(tp)
7575
// So we don't call PyObject_GC_Del here and instead we set the python
7676
// reference to a weak reference so that the C# object can be collected.
7777
GCHandlegc=GCHandle.Alloc(self,GCHandleType.Weak);
78-
Marshal.WriteIntPtr(self.pyHandle,ObjectOffset.magic(self.tpHandle),(IntPtr)gc);
78+
intgcOffset=ObjectOffset.magic(Runtime.PyObject_TYPE(self.pyHandle));
79+
Marshal.WriteIntPtr(self.pyHandle,gcOffset,(IntPtr)gc);
7980
self.gcHandle.Free();
8081
self.gcHandle=gc;
8182
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp