(builtin_name, item, sentinel=None)
| 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(),), |
no test coverage detected