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

Method close

Lib/gzip.py:379–395  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

377 return self.fileobj is None
378
379 def close(self):
380 fileobj = self.fileobj
381 if fileobj is None:
382 return
383 if self._buffer is None or self._buffer.closed:
384 return
385 try:
386 if self.mode == WRITE:
387 self._buffer.flush()
388 fileobj.write(self.compress.flush())
389 write32u(fileobj, self.crc)
390 # self.size may exceed 2 GiB, or even 4 GiB
391 write32u(fileobj, self.size & 0xffffffff)
392 elif self.mode == READ:
393 self._buffer.close()
394 finally:
395 self._close()
396
397 def _close(self):
398 self.fileobj = None

Callers 6

gzopenMethod · 0.95
mainFunction · 0.95
test_with_openMethod · 0.95
open_urlresourceFunction · 0.95
_closeMethod · 0.45

Calls 4

_closeMethod · 0.95
write32uFunction · 0.85
flushMethod · 0.45
writeMethod · 0.45

Tested by 2

test_with_openMethod · 0.76