diff --git a/Objects/abstract.c b/Objects/abstract.c index c2d8db71fdb..99b22db71ba 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -107,6 +107,8 @@ _PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue) PyErr_Clear(); } + if (PyInstance_Check(o)) + return defaultvalue; /* try o.__length_hint__() */ hintmeth = _PyObject_LookupSpecial(o, "__length_hint__", &hintstrobj); if (hintmeth == NULL)