MCPcopy Index your code
hub / github.com/RustPython/RustPython / close

Method close

Lib/tarfile.py:462–482  ·  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

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