MCPcopy Index your code
hub / github.com/python/cpython / run

Method run

Lib/test/test_iter.py:261–284  ·  view source on GitHub ↗
(builtin_name, item, sentinel=None)

Source from the content-addressed store, hash-verified

259 orig = {"iter": iter, "reversed": reversed}
260
261 def run(builtin_name, item, sentinel=None):
262 it = iter(item) if sentinel is None else iter(item, sentinel)
263
264 class CustomStr:
265 def __init__(self, name, iterator):
266 self.name = name
267 self.iterator = iterator
268 def __hash__(self):
269 return hash(self.name)
270 def __eq__(self, other):
271 # Here we exhaust our iterator, possibly changing
272 # its `it_seq` pointer to NULL
273 # The `__reduce__` call should correctly get
274 # the pointers after this call
275 list(self.iterator)
276 return other == self.name
277
278 # del is required here
279 # to not prematurely call __eq__ from
280 # the hash collision with the old key
281 del builtins_dict[builtin_name]
282 builtins_dict[CustomStr(builtin_name, it)] = orig[builtin_name]
283
284 return it.__reduce__()
285
286 types = [
287 (EmptyIterClass(),),

Callers 15

list_casesFunction · 0.45
run_testsFunction · 0.45
setUpModuleFunction · 0.45
run_pythonMethod · 0.45
test_check_zeroMethod · 0.45

Calls 2

CustomStrClass · 0.70
__reduce__Method · 0.45

Tested by

no test coverage detected