diff options
Diffstat (limited to 'Objects/cellobject.c')
-rw-r--r-- | Objects/cellobject.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Objects/cellobject.c b/Objects/cellobject.c index 490afe0..50a3897 100644 --- a/Objects/cellobject.c +++ b/Objects/cellobject.c @@ -51,6 +51,18 @@ cell_dealloc(PyCellObject *op) PyObject_GC_Del(op); } +static int +cell_compare(PyCellObject *a, PyCellObject *b) +{ + if (a->ob_ref == NULL) { + if (b->ob_ref == NULL) + return 0; + return -1; + } else if (b->ob_ref == NULL) + return 1; + return PyObject_Compare(a->ob_ref, b->ob_ref); +} + static PyObject * cell_repr(PyCellObject *op) { @@ -102,7 +114,7 @@ PyTypeObject PyCell_Type = { 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + (cmpfunc)cell_compare, /* tp_compare */ (reprfunc)cell_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ |