mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -43,12 +43,22 @@ enumerate(iter('abc')).
|
|||
|
||||
import unittest
|
||||
from test import test_support
|
||||
from itertools import repeat, count
|
||||
from itertools import repeat
|
||||
from collections import deque
|
||||
from UserList import UserList
|
||||
from __builtin__ import len as _len
|
||||
|
||||
n = 10
|
||||
|
||||
def len(obj):
|
||||
try:
|
||||
return _len(obj)
|
||||
except TypeError:
|
||||
try:
|
||||
return obj._length_cue()
|
||||
except AttributeError:
|
||||
raise TypeError
|
||||
|
||||
class TestInvariantWithoutMutations(unittest.TestCase):
|
||||
|
||||
def test_invariant(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue