@@ -661,7 +661,7 @@ StringDType_richcompare(PyObject *self, PyObject *other, int op)
661
661
StringDTypeObject * sself = (StringDTypeObject * )self ;
662
662
StringDTypeObject * sother = (StringDTypeObject * )other ;
663
663
664
- int eq ;
664
+ int eq = 0 ;
665
665
PyObject * sna = sself -> na_object ;
666
666
PyObject * ona = sother -> na_object ;
667
667
@@ -706,6 +706,23 @@ StringDType_richcompare(PyObject *self, PyObject *other, int op)
706
706
return ret ;
707
707
}
708
708
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
+
709
726
/*
710
727
* This is the basic things that you need to create a Python Type/Class in C.
711
728
* However, there is a slight difference here because we create a
@@ -724,6 +741,7 @@ StringDType_type StringDType = {
724
741
.tp_methods = StringDType_methods ,
725
742
.tp_members = StringDType_members ,
726
743
.tp_richcompare = StringDType_richcompare ,
744
+ .tp_hash = StringDType_hash ,
727
745
}}},
728
746
/* rest, filled in during DTypeMeta initialization */
729
747
};
0 commit comments