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

Method close

Lib/tarfile.py:460–480  ·  view source on GitHub ↗

Close the _Stream object. No operation should be done on it afterwards.

(self)

Source from the content-addressed store, hash-verified

458 self.buf = self.buf[self.bufsize:]
459
460 def close(self):
461 """Close the _Stream object. No operation should be
462 done on it afterwards.
463 """
464 if self.closed:
465 return
466
467 self.closed = True
468 try:
469 if self.mode == "w" and self.comptype != "tar":
470 self.buf += self.cmp.flush()
471
472 if self.mode == "w" and self.buf:
473 self.fileobj.write(self.buf)
474 self.buf = b""
475 if self.comptype == "gz":
476 self.fileobj.write(struct.pack("<L", self.crc))
477 self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFF))
478 finally:
479 if not self._extfileobj:
480 self.fileobj.close()
481
482 def _init_read_gz(self):
483 """Initialize for reading a gzip compressed fileobj.

Callers 9

__del__Method · 0.95
closeMethod · 0.45
__init__Method · 0.45
closeMethod · 0.45
__init__Method · 0.45
openMethod · 0.45
closeMethod · 0.45
__exit__Method · 0.45
is_tarfileFunction · 0.45

Calls 3

flushMethod · 0.45
writeMethod · 0.45
packMethod · 0.45

Tested by

no test coverage detected