@@ -81,7 +81,7 @@ internal static IntPtr ToPython(IPythonDerivedType obj)
81
81
FieldInfo fi = obj . GetType ( ) . GetField ( "__pyobj__" ) ;
82
82
CLRObject self = ( CLRObject ) fi . GetValue ( obj ) ;
83
83
84
- Runtime . Incref ( self . pyHandle ) ;
84
+ Runtime . XIncref ( self . pyHandle ) ;
85
85
86
86
// when the C# constructor creates the python object it starts as a weak
87
87
// reference with a reference count of 0. Now we're passing this object
@@ -153,7 +153,7 @@ internal static Type CreateDerivedType(string name,
153
153
HashSet < string > pyProperties = new HashSet < string > ( ) ;
154
154
if ( py_dict != IntPtr . Zero && Runtime . PyDict_Check ( py_dict ) )
155
155
{
156
- Runtime . Incref ( py_dict ) ;
156
+ Runtime . XIncref ( py_dict ) ;
157
157
using ( PyDict dict = new PyDict ( py_dict ) )
158
158
using ( PyObject keys = dict . Keys ( ) )
159
159
{
@@ -196,7 +196,7 @@ internal static Type CreateDerivedType(string name,
196
196
// Add any additional methods and properties explicitly exposed from Python.
197
197
if ( py_dict != IntPtr . Zero && Runtime . PyDict_Check ( py_dict ) )
198
198
{
199
- Runtime . Incref ( py_dict ) ;
199
+ Runtime . XIncref ( py_dict ) ;
200
200
using ( PyDict dict = new PyDict ( py_dict ) )
201
201
using ( PyObject keys = dict . Keys ( ) )
202
202
{
@@ -588,11 +588,11 @@ public static T InvokeMethod<T>(IPythonDerivedType obj, string methodName, strin
588
588
IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
589
589
try
590
590
{
591
- Runtime . Incref ( self . pyHandle ) ;
591
+ Runtime . XIncref ( self . pyHandle ) ;
592
592
PyObject pyself = new PyObject ( self . pyHandle ) ;
593
593
disposeList . Add ( pyself ) ;
594
594
595
- Runtime . Incref ( Runtime . PyNone ) ;
595
+ Runtime . XIncref ( Runtime . PyNone ) ;
596
596
PyObject pynone = new PyObject ( Runtime . PyNone ) ;
597
597
disposeList . Add ( pynone ) ;
598
598
@@ -649,11 +649,11 @@ public static void InvokeMethodVoid(IPythonDerivedType obj, string methodName, s
649
649
IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
650
650
try
651
651
{
652
- Runtime . Incref ( self . pyHandle ) ;
652
+ Runtime . XIncref ( self . pyHandle ) ;
653
653
PyObject pyself = new PyObject ( self . pyHandle ) ;
654
654
disposeList . Add ( pyself ) ;
655
655
656
- Runtime . Incref ( Runtime . PyNone ) ;
656
+ Runtime . XIncref ( Runtime . PyNone ) ;
657
657
PyObject pynone = new PyObject ( Runtime . PyNone ) ;
658
658
disposeList . Add ( pynone ) ;
659
659
@@ -710,7 +710,7 @@ public static T InvokeGetProperty<T>(IPythonDerivedType obj, string propertyName
710
710
IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
711
711
try
712
712
{
713
- Runtime . Incref ( self . pyHandle ) ;
713
+ Runtime . XIncref ( self . pyHandle ) ;
714
714
using ( PyObject pyself = new PyObject ( self . pyHandle ) )
715
715
using ( PyObject pyvalue = pyself . GetAttr ( propertyName ) )
716
716
return ( T ) pyvalue . AsManagedObject ( typeof ( T ) ) ;
@@ -732,7 +732,7 @@ public static void InvokeSetProperty<T>(IPythonDerivedType obj, string propertyN
732
732
IntPtr gs = Runtime . PyGILState_Ensure ( ) ;
733
733
try
734
734
{
735
- Runtime . Incref ( self . pyHandle ) ;
735
+ Runtime . XIncref ( self . pyHandle ) ;
736
736
using ( PyObject pyself = new PyObject ( self . pyHandle ) )
737
737
using ( PyObject pyvalue = new PyObject ( Converter . ToPythonImplicit ( value ) ) )
738
738
pyself . SetAttr ( propertyName , pyvalue ) ;
@@ -766,11 +766,11 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, Objec
766
766
FieldInfo fi = obj . GetType ( ) . GetField ( "__pyobj__" ) ;
767
767
fi . SetValue ( obj , self ) ;
768
768
769
- Runtime . Incref ( self . pyHandle ) ;
769
+ Runtime . XIncref ( self . pyHandle ) ;
770
770
PyObject pyself = new PyObject ( self . pyHandle ) ;
771
771
disposeList . Add ( pyself ) ;
772
772
773
- Runtime . Incref ( Runtime . PyNone ) ;
773
+ Runtime . XIncref ( Runtime . PyNone ) ;
774
774
PyObject pynone = new PyObject ( Runtime . PyNone ) ;
775
775
disposeList . Add ( pynone ) ;
776
776
@@ -806,7 +806,7 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, Objec
806
806
// This doesn't actually destroy the object, it just sets the reference to this object
807
807
// to be a weak reference and it will be destroyed when the C# object is destroyed.
808
808
if ( null != self )
809
- Runtime . Decref ( self . pyHandle ) ;
809
+ Runtime . XDecref ( self . pyHandle ) ;
810
810
811
811
Runtime . PyGILState_Release ( gs ) ;
812
812
}
@@ -848,7 +848,7 @@ public static void Finalize(IPythonDerivedType obj)
848
848
// python object.
849
849
IntPtr dict = Marshal . ReadIntPtr ( self . pyHandle , ObjectOffset . DictOffset ( self . pyHandle ) ) ;
850
850
if ( dict != IntPtr . Zero )
851
- Runtime . Decref ( dict ) ;
851
+ Runtime . XDecref ( dict ) ;
852
852
Runtime . PyObject_GC_Del ( self . pyHandle ) ;
853
853
self . gcHandle . Free ( ) ;
854
854
}
0 commit comments