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

Class IteratorWrapper

Lib/wsgiref/validate.py:260–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258 return IteratorWrapper(self.iterator, None)
259
260class IteratorWrapper:
261
262 def __init__(self, wsgi_iterator, check_start_response):
263 self.original_iterator = wsgi_iterator
264 self.iterator = iter(wsgi_iterator)
265 self.closed = False
266 self.check_start_response = check_start_response
267
268 def __iter__(self):
269 return self
270
271 def __next__(self):
272 assert_(not self.closed,
273 "Iterator read after closed")
274 v = next(self.iterator)
275 if type(v) is not bytes:
276 assert_(False, "Iterator yielded non-bytestring (%r)" % (v,))
277 if self.check_start_response is not None:
278 assert_(self.check_start_response,
279 "The application returns and we started iterating over its body, but start_response has not yet been called")
280 self.check_start_response = None
281 return v
282
283 def close(self):
284 self.closed = True
285 if hasattr(self.original_iterator, 'close'):
286 self.original_iterator.close()
287
288 def __del__(self):
289 if not self.closed:
290 sys.stderr.write(
291 "Iterator garbage collected without being closed")
292 assert_(self.closed,
293 "Iterator garbage collected without being closed")
294
295def check_environ(environ):
296 assert_(type(environ) is dict,

Callers 2

lint_appFunction · 0.85
__iter__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…