(_py: Python, obj: *mut ffi::PyObject)
| 144 | } |
| 145 | |
| 146 | unsafe fn dealloc(_py: Python, obj: *mut ffi::PyObject) { |
| 147 | //println!("BaseObject::dealloc({:?})", ptr); |
| 148 | // Unfortunately, there is no PyType_GenericFree, so |
| 149 | // we have to manually un-do the work of PyType_GenericAlloc: |
| 150 | let ty = ffi::Py_TYPE(obj); |
| 151 | if ffi::PyType_IS_GC(ty) != 0 { |
| 152 | ffi::PyObject_GC_Del(obj as *mut libc::c_void); |
| 153 | } else { |
| 154 | ffi::PyObject_Free(obj as *mut libc::c_void); |
| 155 | } |
| 156 | // For heap types, PyType_GenericAlloc calls INCREF on the type objects, |
| 157 | // so we need to call DECREF here: |
| 158 | if ffi::PyType_HasFeature(ty, ffi::Py_TPFLAGS_HEAPTYPE) != 0 { |
| 159 | ffi::Py_DECREF(ty as *mut ffi::PyObject); |
| 160 | } |
| 161 | } |
| 162 | } |
nothing calls this directly
no test coverage detected