PEP 205, Weak References -- initial checkin.

This commit is contained in:
Fred Drake 2001-02-01 05:27:45 +00:00
parent 2de7471d69
commit 41deb1efc2
9 changed files with 1158 additions and 4 deletions

View file

@ -246,8 +246,8 @@ typedef struct _typeobject {
/* rich comparisons */
richcmpfunc tp_richcompare;
/* More spares */
long tp_xxx8;
/* weak reference enabler */
long tp_weaklistoffset;
#ifdef COUNT_ALLOCS
/* these must be last */
@ -284,6 +284,8 @@ extern DL_IMPORT(int) PyCallable_Check(PyObject *);
extern DL_IMPORT(int) PyNumber_Coerce(PyObject **, PyObject **);
extern DL_IMPORT(int) PyNumber_CoerceEx(PyObject **, PyObject **);
extern DL_IMPORT(int) (*PyObject_ClearWeakRefs)(PyObject *);
/* Helpers for printing recursive container types */
extern DL_IMPORT(int) Py_ReprEnter(PyObject *);
extern DL_IMPORT(void) Py_ReprLeave(PyObject *);
@ -418,7 +420,7 @@ extern DL_IMPORT(long) _Py_RefTotal;
#define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++)
#define Py_DECREF(op) \
if (--_Py_RefTotal, --(op)->ob_refcnt != 0) \
if (--_Py_RefTotal, (--((op)->ob_refcnt) != 0)) \
; \
else \
_Py_Dealloc((PyObject *)(op))