mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
Convert iterator __len__() methods to a private API.
This commit is contained in:
parent
9ceebd5445
commit
6b27cda643
16 changed files with 169 additions and 94 deletions
|
@ -221,7 +221,7 @@ builtin_filter(PyObject *self, PyObject *args)
|
|||
goto Fail_arg;
|
||||
|
||||
/* Guess a result list size. */
|
||||
len = PyObject_Size(seq);
|
||||
len = _PyObject_LengthCue(seq);
|
||||
if (len < 0) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
|
||||
!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||
|
@ -873,7 +873,7 @@ builtin_map(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
/* Update len. */
|
||||
curlen = PyObject_Size(curseq);
|
||||
curlen = _PyObject_LengthCue(curseq);
|
||||
if (curlen < 0) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
|
||||
!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||
|
@ -2108,7 +2108,7 @@ builtin_zip(PyObject *self, PyObject *args)
|
|||
len = -1; /* unknown */
|
||||
for (i = 0; i < itemsize; ++i) {
|
||||
PyObject *item = PyTuple_GET_ITEM(args, i);
|
||||
int thislen = PyObject_Size(item);
|
||||
int thislen = _PyObject_LengthCue(item);
|
||||
if (thislen < 0) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
|
||||
!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue