@@ -2054,17 +2054,20 @@ dictiter_dealloc(dictiterobject *di)
20542054 PyObject_Del (di );
20552055}
20562056
2057- static int
2057+ static PyObject *
20582058dictiter_len (dictiterobject * di )
20592059{
2060+ int len = 0 ;
20602061 if (di -> di_dict != NULL && di -> di_used == di -> di_dict -> ma_used )
2061- return di -> len ;
2062- return 0 ;
2062+ len = di -> len ;
2063+ return PyInt_FromLong ( len ) ;
20632064}
20642065
2065- static PySequenceMethods dictiter_as_sequence = {
2066- (inquiry )dictiter_len , /* sq_length */
2067- 0 , /* sq_concat */
2066+ PyDoc_STRVAR (length_cue_doc , "Private method returning an estimate of len(list(it))." );
2067+
2068+ static PyMethodDef dictiter_methods [] = {
2069+ {"_length_cue" , (PyCFunction )dictiter_len , METH_NOARGS , length_cue_doc },
2070+ {NULL , NULL } /* sentinel */
20682071};
20692072
20702073static PyObject * dictiter_iternextkey (dictiterobject * di )
@@ -2120,7 +2123,7 @@ PyTypeObject PyDictIterKey_Type = {
21202123 0 , /* tp_compare */
21212124 0 , /* tp_repr */
21222125 0 , /* tp_as_number */
2123- & dictiter_as_sequence , /* tp_as_sequence */
2126+ 0 , /* tp_as_sequence */
21242127 0 , /* tp_as_mapping */
21252128 0 , /* tp_hash */
21262129 0 , /* tp_call */
@@ -2136,6 +2139,8 @@ PyTypeObject PyDictIterKey_Type = {
21362139 0 , /* tp_weaklistoffset */
21372140 PyObject_SelfIter , /* tp_iter */
21382141 (iternextfunc )dictiter_iternextkey , /* tp_iternext */
2142+ dictiter_methods , /* tp_methods */
2143+ 0 ,
21392144};
21402145
21412146static PyObject * dictiter_iternextvalue (dictiterobject * di )
@@ -2191,7 +2196,7 @@ PyTypeObject PyDictIterValue_Type = {
21912196 0 , /* tp_compare */
21922197 0 , /* tp_repr */
21932198 0 , /* tp_as_number */
2194- & dictiter_as_sequence , /* tp_as_sequence */
2199+ 0 , /* tp_as_sequence */
21952200 0 , /* tp_as_mapping */
21962201 0 , /* tp_hash */
21972202 0 , /* tp_call */
@@ -2207,6 +2212,8 @@ PyTypeObject PyDictIterValue_Type = {
22072212 0 , /* tp_weaklistoffset */
22082213 PyObject_SelfIter , /* tp_iter */
22092214 (iternextfunc )dictiter_iternextvalue , /* tp_iternext */
2215+ dictiter_methods , /* tp_methods */
2216+ 0 ,
22102217};
22112218
22122219static PyObject * dictiter_iternextitem (dictiterobject * di )
@@ -2276,7 +2283,7 @@ PyTypeObject PyDictIterItem_Type = {
22762283 0 , /* tp_compare */
22772284 0 , /* tp_repr */
22782285 0 , /* tp_as_number */
2279- & dictiter_as_sequence , /* tp_as_sequence */
2286+ 0 , /* tp_as_sequence */
22802287 0 , /* tp_as_mapping */
22812288 0 , /* tp_hash */
22822289 0 , /* tp_call */
@@ -2292,4 +2299,6 @@ PyTypeObject PyDictIterItem_Type = {
22922299 0 , /* tp_weaklistoffset */
22932300 PyObject_SelfIter , /* tp_iter */
22942301 (iternextfunc )dictiter_iternextitem , /* tp_iternext */
2302+ dictiter_methods , /* tp_methods */
2303+ 0 ,
22952304};
0 commit comments