MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / close

Method close

tools/python-3.11.9-amd64/Lib/tarfile.py:453–473  ·  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

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