Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit 8e3c028

Browse files
committed
Apply Reference type usage
1 parent 1428af3 commit 8e3c028

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/runtime/typemanager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,8 @@ public static IntPtr CreateObjectType()
891891
throw new PythonException();
892892
}
893893
const string code = "class A(object): pass";
894-
IntPtr res = Runtime.PyRun_String(code, RunFlagType.File, globals, globals);
894+
var resRef = Runtime.PyRun_String(code, RunFlagType.File, globals, globals);
895+
IntPtr res = resRef.DangerousGetAddress();
895896
if (res == IntPtr.Zero)
896897
{
897898
try
@@ -903,7 +904,7 @@ public static IntPtr CreateObjectType()
903904
Runtime.XDecref(globals);
904905
}
905906
}
906-
Runtime.XDecref(res);
907+
resRef.Dispose();
907908
IntPtr A = Runtime.PyDict_GetItemString(globals, "A");
908909
Debug.Assert(A != IntPtr.Zero);
909910
Runtime.XIncref(A);

0 commit comments

Comments
 (0)