@@ -50,7 +50,7 @@ public void CollectBasicObject()
5050 } ;
5151
5252 Assert . IsFalse ( called , "The event handler was called before it was installed" ) ;
53- Finalizer . Instance . CollectOnce += handler ;
53+ Finalizer . Instance . BeforeCollect += handler ;
5454
5555 IntPtr pyObj = MakeAGarbage ( out var shortWeak , out var longWeak ) ;
5656 FullGCCollect ( ) ;
@@ -81,7 +81,7 @@ public void CollectBasicObject()
8181 }
8282 finally
8383 {
84- Finalizer . Instance . CollectOnce -= handler ;
84+ Finalizer . Instance . BeforeCollect -= handler ;
8585 }
8686 Assert . IsTrue ( called , "The event handler was not called during finalization" ) ;
8787 Assert . GreaterOrEqual ( objectCount , 1 ) ;
@@ -121,7 +121,7 @@ private static IntPtr MakeAGarbage(out WeakReference shortWeak, out WeakReferenc
121121 IntPtr handle = IntPtr . Zero ;
122122 WeakReference @short = null , @long = null ;
123123 // must create Python object in the thread where we have GIL
124- IntPtr val = PyLong . FromLong ( 1024 ) ;
124+ IntPtr val = Runtime . Runtime . PyLong_FromLongLong ( 1024 ) . DangerousMoveToPointerOrNull ( ) ;
125125 // must create temp object in a different thread to ensure it is not present
126126 // when conservatively scanning stack for GC roots.
127127 // see https://xamarin.github.io/bugzilla-archives/17/17593/bug.html
@@ -234,7 +234,7 @@ private static IntPtr CreateStringGarbage()
234234 {
235235 PyString s1 = new PyString ( "test_string" ) ;
236236 // s2 steal a reference from s1
237- PyString s2 = new PyString ( s1 . Handle ) ;
237+ PyString s2 = new PyString ( StolenReference . DangerousFromPointer ( s1 . Handle ) ) ;
238238 return s1 . Handle ;
239239 }
240240 }
0 commit comments