summaryrefslogtreecommitdiffstats
path: root/Include/objimpl.h
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-02-02 18:17:30 (GMT)
committerFred Drake <fdrake@acm.org>2001-02-02 18:17:30 (GMT)
commit033f31270cb424efdb72abb03d925235f18d034d (patch)
treee5947972e470b7174e668a9e32f35e4c9429503b /Include/objimpl.h
parent26d1f1443300526afe3b63fe9c5c7ef4f6a5e33d (diff)
downloadcpython-033f31270cb424efdb72abb03d925235f18d034d.zip
cpython-033f31270cb424efdb72abb03d925235f18d034d.tar.gz
cpython-033f31270cb424efdb72abb03d925235f18d034d.tar.bz2
Use a type flag to determine the applicability of the tp_weaklistoffset
field. This should avoid binary incompatibility problems with older modules that have not been recompiled.
Diffstat (limited to 'Include/objimpl.h')
-rw-r--r--Include/objimpl.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Include/objimpl.h b/Include/objimpl.h
index 93c5b23..9c13e71 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -271,7 +271,9 @@ extern DL_IMPORT(void) _PyGC_Dump(PyGC_Head *);
#endif /* WITH_CYCLE_GC */
/* Test if a type supports weak references */
-#define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
+#define PyType_SUPPORTS_WEAKREFS(t) \
+ (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \
+ && ((t)->tp_weaklistoffset > 0))
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset))