@@ -81,7 +81,7 @@ internal static IntPtr ToPython(IPythonDerivedType obj)
8181 FieldInfo fi = obj . GetType ( ) . GetField ( "__pyobj__" ) ;
8282 CLRObject self = ( CLRObject ) fi . GetValue ( obj ) ;
8383
84- Runtime . Incref ( self . pyHandle ) ;
84+ Runtime . XIncref ( self . pyHandle ) ;
8585
8686 // when the C# constructor creates the python object it starts as a weak
8787 // reference with a reference count of 0. Now we're passing this object
@@ -153,7 +153,7 @@ internal static Type CreateDerivedType(string name,
153153 HashSet < string > pyProperties = new HashSet < string > ( ) ;
154154 if ( py_dict != IntPtr . Zero && Runtime . PyDict_Check ( py_dict ) )
155155 {
156- Runtime . Incref ( py_dict ) ;
156+ Runtime . XIncref ( py_dict ) ;
157157 using ( PyDict dict = new PyDict ( py_dict ) )
158158 using ( PyObject keys = dict . Keys ( ) )
159159 {
@@ -196,7 +196,7 @@ internal static Type CreateDerivedType(string name,
196196 // Add any additional methods and properties explicitly exposed from Python.
197197 if ( py_dict != IntPtr . Zero && Runtime . PyDict_Check ( py_dict ) )
198198 {
199- Runtime . Incref ( py_dict ) ;
199+ Runtime . XIncref ( py_dict ) ;
200200 using ( PyDict dict = new PyDict ( py_dict ) )
201201 using ( PyObject keys = dict . Keys ( ) )
202202 {
@@ -588,11 +588,11 @@ public static T InvokeMethod<T>(IPythonDerivedType obj, string methodName, strin
588588 IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
589589 try
590590 {
591- Runtime . Incref ( self . pyHandle ) ;
591+ Runtime . XIncref ( self . pyHandle ) ;
592592 PyObject pyself = new PyObject ( self . pyHandle ) ;
593593 disposeList . Add ( pyself ) ;
594594
595- Runtime . Incref ( Runtime . PyNone ) ;
595+ Runtime . XIncref ( Runtime . PyNone ) ;
596596 PyObject pynone = new PyObject ( Runtime . PyNone ) ;
597597 disposeList . Add ( pynone ) ;
598598
@@ -649,11 +649,11 @@ public static void InvokeMethodVoid(IPythonDerivedType obj, string methodName, s
649649 IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
650650 try
651651 {
652- Runtime . Incref ( self . pyHandle ) ;
652+ Runtime . XIncref ( self . pyHandle ) ;
653653 PyObject pyself = new PyObject ( self . pyHandle ) ;
654654 disposeList . Add ( pyself ) ;
655655
656- Runtime . Incref ( Runtime . PyNone ) ;
656+ Runtime . XIncref ( Runtime . PyNone ) ;
657657 PyObject pynone = new PyObject ( Runtime . PyNone ) ;
658658 disposeList . Add ( pynone ) ;
659659
@@ -710,7 +710,7 @@ public static T InvokeGetProperty<T>(IPythonDerivedType obj, string propertyName
710710 IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
711711 try
712712 {
713- Runtime . Incref ( self . pyHandle ) ;
713+ Runtime . XIncref ( self . pyHandle ) ;
714714 using ( PyObject pyself = new PyObject ( self . pyHandle ) )
715715 using ( PyObject pyvalue = pyself . GetAttr ( propertyName ) )
716716 return ( T ) pyvalue . AsManagedObject ( typeof ( T ) ) ;
@@ -732,7 +732,7 @@ public static void InvokeSetProperty<T>(IPythonDerivedType obj, string propertyN
732732 IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
733733 try
734734 {
735- Runtime . Incref ( self . pyHandle ) ;
735+ Runtime . XIncref ( self . pyHandle ) ;
736736 using ( PyObject pyself = new PyObject ( self . pyHandle ) )
737737 using ( PyObject pyvalue = new PyObject ( Converter . ToPythonImplicit ( value ) ) )
738738 pyself . SetAttr ( propertyName , pyvalue ) ;
@@ -766,11 +766,11 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, Objec
766766 FieldInfo fi = obj . GetType ( ) . GetField ( "__pyobj__" ) ;
767767 fi . SetValue ( obj , self ) ;
768768
769- Runtime . Incref ( self . pyHandle ) ;
769+ Runtime . XIncref ( self . pyHandle ) ;
770770 PyObject pyself = new PyObject ( self . pyHandle ) ;
771771 disposeList . Add ( pyself ) ;
772772
773- Runtime . Incref ( Runtime . PyNone ) ;
773+ Runtime . XIncref ( Runtime . PyNone ) ;
774774 PyObject pynone = new PyObject ( Runtime . PyNone ) ;
775775 disposeList . Add ( pynone ) ;
776776
@@ -806,7 +806,7 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, Objec
806806 // This doesn't actually destroy the object, it just sets the reference to this object
807807 // to be a weak reference and it will be destroyed when the C# object is destroyed.
808808 if ( null != self )
809- Runtime . Decref ( self . pyHandle ) ;
809+ Runtime . XDecref ( self . pyHandle ) ;
810810
811811 Runtime . PyGILState_Release ( gs ) ;
812812 }
@@ -848,7 +848,7 @@ public static void Finalize(IPythonDerivedType obj)
848848 // python object.
849849 IntPtr dict = Marshal . ReadIntPtr ( self . pyHandle , ObjectOffset . DictOffset ( self . pyHandle ) ) ;
850850 if ( dict != IntPtr . Zero )
851- Runtime . Decref ( dict ) ;
851+ Runtime . XDecref ( dict ) ;
852852 Runtime . PyObject_GC_Del ( self . pyHandle ) ;
853853 self . gcHandle . Free ( ) ;
854854 }
0 commit comments