@@ -42,7 +42,7 @@ public void TestConvertSingleToManaged(
4242 var pyFloat = new PyFloat ( testValue ) ;
4343
4444 object convertedValue ;
45- var converted = Converter . ToManaged ( pyFloat . Handle , typeof ( float ) , out convertedValue , false ) ;
45+ var converted = Converter . ToManaged ( pyFloat , typeof ( float ) , out convertedValue , false ) ;
4646
4747 Assert . IsTrue ( converted ) ;
4848 Assert . IsTrue ( ( ( float ) convertedValue ) . Equals ( testValue ) ) ;
@@ -56,7 +56,7 @@ public void TestConvertDoubleToManaged(
5656 var pyFloat = new PyFloat ( testValue ) ;
5757
5858 object convertedValue ;
59- var converted = Converter . ToManaged ( pyFloat . Handle , typeof ( double ) , out convertedValue , false ) ;
59+ var converted = Converter . ToManaged ( pyFloat , typeof ( double ) , out convertedValue , false ) ;
6060
6161 Assert . IsTrue ( converted ) ;
6262 Assert . IsTrue ( ( ( double ) convertedValue ) . Equals ( testValue ) ) ;
@@ -77,7 +77,7 @@ public void CovertTypeError()
7777 object value ;
7878 try
7979 {
80- bool res = Converter . ToManaged ( s . Handle , type , out value , true ) ;
80+ bool res = Converter . ToManaged ( s , type , out value , true ) ;
8181 Assert . IsFalse ( res ) ;
8282 var bo = Exceptions . ExceptionMatches ( Exceptions . TypeError ) ;
8383 Assert . IsTrue ( Exceptions . ExceptionMatches ( Exceptions . TypeError )
@@ -96,13 +96,13 @@ public void ConvertOverflow()
9696 {
9797 using ( var num = new PyInt ( ulong . MaxValue ) )
9898 {
99- IntPtr largeNum = PyRuntime . PyNumber_Add ( num . Handle , num . Handle ) ;
99+ using var largeNum = PyRuntime . PyNumber_Add ( num , num ) ;
100100 try
101101 {
102102 object value ;
103103 foreach ( var type in _numTypes )
104104 {
105- bool res = Converter . ToManaged ( largeNum , type , out value , true ) ;
105+ bool res = Converter . ToManaged ( largeNum . BorrowOrThrow ( ) , type , out value , true ) ;
106106 Assert . IsFalse ( res ) ;
107107 Assert . IsTrue ( Exceptions . ExceptionMatches ( Exceptions . OverflowError ) ) ;
108108 Exceptions . Clear ( ) ;
@@ -111,7 +111,6 @@ public void ConvertOverflow()
111111 finally
112112 {
113113 Exceptions . Clear ( ) ;
114- PyRuntime . XDecref ( largeNum ) ;
115114 }
116115 }
117116 }
@@ -147,7 +146,7 @@ public void RawListProxy()
147146 {
148147 var list = new List < string > { "hello" , "world" } ;
149148 var listProxy = PyObject . FromManagedObject ( list ) ;
150- var clrObject = ( CLRObject ) ManagedType . GetManagedObject ( listProxy . Handle ) ;
149+ var clrObject = ( CLRObject ) ManagedType . GetManagedObject ( listProxy ) ;
151150 Assert . AreSame ( list , clrObject . inst ) ;
152151 }
153152
@@ -156,7 +155,7 @@ public void RawPyObjectProxy()
156155 {
157156 var pyObject = "hello world!" . ToPython ( ) ;
158157 var pyObjectProxy = PyObject . FromManagedObject ( pyObject ) ;
159- var clrObject = ( CLRObject ) ManagedType . GetManagedObject ( pyObjectProxy . Handle ) ;
158+ var clrObject = ( CLRObject ) ManagedType . GetManagedObject ( pyObjectProxy ) ;
160159 Assert . AreSame ( pyObject , clrObject . inst ) ;
161160
162161 var proxiedHandle = pyObjectProxy . GetAttr ( "Handle" ) . As < IntPtr > ( ) ;
0 commit comments