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

Method __del__

Lib/_pyio.py:398–415  ·  view source on GitHub ↗

Destructor. Calls close().

(self)

Source from the content-addressed store, hash-verified

396 self.__closed = True
397
398 def __del__(self):
399 """Destructor. Calls close()."""
400 try:
401 closed = self.closed
402 except AttributeError:
403 # If getting closed fails, then the object is probably
404 # in an unusable state, so ignore.
405 return
406
407 if closed:
408 return
409
410 if dealloc_warn := getattr(self, "_dealloc_warn", None):
411 dealloc_warn(self)
412
413 # If close() fails, the caller logs the exception with
414 # sys.unraisablehook. close() must be called at the end at __del__().
415 self.close()
416
417 ### Inquiries ###
418

Callers

nothing calls this directly

Calls 1

closeMethod · 0.95

Tested by

no test coverage detected