File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,10 +24,12 @@ public static void StartAndStopTwice()
2424 public static void LoadDefaultArgs ( )
2525 {
2626 using ( new PythonEngine ( ) )
27- using ( var argv = new PyList ( Runtime . Runtime . PySys_GetObject ( "argv" ) ) )
2827 {
29- Runtime . Runtime . XIncref ( argv . Handle ) ;
30- Assert . AreNotEqual ( 0 , argv . Length ( ) ) ;
28+ var argvref = new BorrowedReference ( Runtime . Runtime . PySys_GetObject ( "argv" ) ) ;
29+ using ( var argv = new PyList ( argvref . DangerousGetAddress ( ) ) )
30+ {
31+ Assert . AreNotEqual ( 0 , argv . Length ( ) ) ;
32+ }
3133 }
3234 }
3335
@@ -36,11 +38,13 @@ public static void LoadSpecificArgs()
3638 {
3739 var args = new [ ] { "test1" , "test2" } ;
3840 using ( new PythonEngine ( args ) )
39- using ( var argv = new PyList ( Runtime . Runtime . PySys_GetObject ( "argv" ) ) )
4041 {
41- Runtime . Runtime . XIncref ( argv . Handle ) ;
42- Assert . AreEqual ( args [ 0 ] , argv [ 0 ] . ToString ( ) ) ;
43- Assert . AreEqual ( args [ 1 ] , argv [ 1 ] . ToString ( ) ) ;
42+ var argvref = new BorrowedReference ( Runtime . Runtime . PySys_GetObject ( "argv" ) ) ;
43+ using ( var argv = new PyList ( argvref . DangerousGetAddress ( ) ) )
44+ {
45+ Assert . AreEqual ( args [ 0 ] , argv [ 0 ] . ToString ( ) ) ;
46+ Assert . AreEqual ( args [ 1 ] , argv [ 1 ] . ToString ( ) ) ;
47+ }
4448 }
4549 }
4650
You can’t perform that action at this time.
0 commit comments