@@ -661,7 +661,7 @@ StringDType_richcompare(PyObject *self, PyObject *other, int op)
661661 StringDTypeObject * sself = (StringDTypeObject * )self ;
662662 StringDTypeObject * sother = (StringDTypeObject * )other ;
663663
664- int eq ;
664+ int eq = 0 ;
665665 PyObject * sna = sself -> na_object ;
666666 PyObject * ona = sother -> na_object ;
667667
@@ -706,6 +706,23 @@ StringDType_richcompare(PyObject *self, PyObject *other, int op)
706706 return ret ;
707707}
708708
709+ static Py_hash_t
710+ StringDType_hash (PyObject * self )
711+ {
712+ StringDTypeObject * sself = (StringDTypeObject * )self ;
713+ PyObject * hash_tup = NULL ;
714+ if (sself -> na_object != NULL ) {
715+ hash_tup = Py_BuildValue ("(iO)" , sself -> coerce , sself -> na_object );
716+ }
717+ else {
718+ hash_tup = Py_BuildValue ("(i)" , sself -> coerce );
719+ }
720+
721+ Py_hash_t ret = PyObject_Hash (hash_tup );
722+ Py_DECREF (hash_tup );
723+ return ret ;
724+ }
725+
709726/*
710727 * This is the basic things that you need to create a Python Type/Class in C.
711728 * However, there is a slight difference here because we create a
@@ -724,6 +741,7 @@ StringDType_type StringDType = {
724741 .tp_methods = StringDType_methods ,
725742 .tp_members = StringDType_members ,
726743 .tp_richcompare = StringDType_richcompare ,
744+ .tp_hash = StringDType_hash ,
727745 }}},
728746 /* rest, filled in during DTypeMeta initialization */
729747};
0 commit comments