You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Increment the reference count for object o. The object may be
95
+
// NULL, in which case the function has no effect.
96
+
func (self*PyObject) IncRef() {
97
+
C.Py_IncRef(self.ptr)
98
+
}
99
+
100
+
// void Py_DecRef(PyObject *o)
101
+
// Decrement the reference count for object o. If the object is
102
+
// NULL, nothing happens. If the reference count reaches zero, the
103
+
// object’s type’s deallocation function (which must not be NULL) is
104
+
// invoked.
105
+
// WARNING: The deallocation function can cause arbitrary Python
106
+
// code to be invoked. See the warnings and instructions in the
107
+
// Python docs, and consider using Clear instead.
108
+
func (self*PyObject) DecRef() {
109
+
C.Py_DecRef(self.ptr)
110
+
}
111
+
112
+
// void Py_CLEAR(PyObject *o)
113
+
// Clear sets the PyObject's internal pointer to nil
114
+
// before calling Py_DecRef. This avoids the potential issues with
115
+
// Python code called by the deallocator referencing invalid,
116
+
// partially-deallocated data.
117
+
func (self*PyObject) Clear() {
118
+
tmp:=self.ptr
119
+
self.ptr=nil
120
+
C.Py_DecRef(tmp)
121
+
}
122
+
90
123
// int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
91
124
// Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds.
92
125
func (self*PyObject) HasAttr(attr_name*PyObject) int {
0 commit comments