File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -344,11 +344,18 @@ given type object has a specified feature.
344344
345345#define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5)
346346
347+ /* Objects which are weakly referencable if their tp_weaklistoffset is >0 */
348+ /* XXX Should this have the same value as Py_TPFLAGS_HAVE_RICHCOMPARE?
349+ * These both indicate a feature that appeared in the same alpha release.
350+ */
351+ #define Py_TPFLAGS_HAVE_WEAKREFS (1L<<6)
352+
347353#define Py_TPFLAGS_DEFAULT ( \
348354 Py_TPFLAGS_HAVE_GETCHARBUFFER | \
349355 Py_TPFLAGS_HAVE_SEQUENCE_IN | \
350356 Py_TPFLAGS_HAVE_INPLACEOPS | \
351357 Py_TPFLAGS_HAVE_RICHCOMPARE | \
358+ Py_TPFLAGS_HAVE_WEAKREFS | \
352359 0)
353360
354361#define PyType_HasFeature (t ,f ) (((t)->tp_flags & (f)) != 0)
Original file line number Diff line number Diff line change @@ -271,7 +271,9 @@ extern DL_IMPORT(void) _PyGC_Dump(PyGC_Head *);
271271#endif /* WITH_CYCLE_GC */
272272
273273/* Test if a type supports weak references */
274- #define PyType_SUPPORTS_WEAKREFS (t ) ((t)->tp_weaklistoffset > 0)
274+ #define PyType_SUPPORTS_WEAKREFS (t ) \
275+ (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \
276+ && ((t)->tp_weaklistoffset > 0))
275277
276278#define PyObject_GET_WEAKREFS_LISTPTR (o ) \
277279 ((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset))
You can’t perform that action at this time.
0 commit comments