diff -r 61463ff7dc68 Objects/abstract.c --- a/Objects/abstract.c Wed Oct 23 22:03:45 2013 +0200 +++ b/Objects/abstract.c Thu Oct 24 00:41:58 2013 +0300 @@ -82,15 +82,17 @@ PyObject *hint, *result; Py_ssize_t res; _Py_IDENTIFIER(__length_hint__); - res = PyObject_Length(o); - if (res < 0 && PyErr_Occurred()) { - if (!PyErr_ExceptionMatches(PyExc_TypeError)) { - return -1; + if (_PyObject_HasLen(o)) { + res = PyObject_Length(o); + if (res < 0 && PyErr_Occurred()) { + if (!PyErr_ExceptionMatches(PyExc_TypeError)) { + return -1; + } + PyErr_Clear(); } - PyErr_Clear(); - } - else { - return res; + else { + return res; + } } hint = _PyObject_LookupSpecial(o, &PyId___length_hint__); if (hint == NULL) {