Index: Include/object.h =================================================================== --- Include/object.h (revision 65957) +++ Include/object.h (working copy) @@ -143,7 +143,7 @@ /* buffer interface */ typedef struct bufferinfo { void *buf; - PyObject *obj; /* borrowed reference */ + PyObject *obj; /* owned reference */ Py_ssize_t len; Py_ssize_t itemsize; /* This is Py_ssize_t so it can be pointed to by strides in simple case.*/ @@ -648,12 +648,34 @@ (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op))) #endif /* !Py_TRACE_REFS */ +static +int Callme(PyObject *op) { + PyObject *x = op; + if(x->ob_refcnt > 1500) + { + int y = 2; + } + return 0; +} + +static +int Callme2(PyObject *op) { + PyObject *x = op; + if(x->ob_refcnt > 1500) + { + int y = 2; + } + return 0; +} + #define Py_INCREF(op) ( \ _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ + Callme((PyObject*)(op)), \ ((PyObject*)(op))->ob_refcnt++) #define Py_DECREF(op) \ if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ + Callme((PyObject*)(op)), \ --((PyObject*)(op))->ob_refcnt != 0) \ _Py_CHECK_REFCNT(op) \ else \ Index: Objects/abstract.c =================================================================== --- Objects/abstract.c (revision 65957) +++ Objects/abstract.c (working copy) @@ -305,6 +305,8 @@ *buffer_len = view.len; if (pb->bf_releasebuffer != NULL) (*pb->bf_releasebuffer)(obj, &view); + if(view.obj) + Py_DECREF(view.obj); return 0; }