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

Method close

Lib/_pyio.py:1804–1816  ·  view source on GitHub ↗

Close the file. A closed file cannot be used for further I/O operations. close() may be called more than once without error.

(self)

Source from the content-addressed store, hash-verified

1802 return size
1803
1804 def close(self):
1805 """Close the file.
1806
1807 A closed file cannot be used for further I/O operations. close() may be
1808 called more than once without error.
1809 """
1810 if not self.closed:
1811 self._stat_atopen = None
1812 try:
1813 if self._closefd and self._fd >= 0:
1814 os.close(self._fd)
1815 finally:
1816 super().close()
1817
1818 def seekable(self):
1819 """True if file supports random-access."""

Callers 12

testErrorsMethod · 0.95
testAblesMethod · 0.95
testUnicodeOpenMethod · 0.95
testBytesOpenMethod · 0.95
testUtf8BytesOpenMethod · 0.95
testBooleanFdMethod · 0.95
testBadModeArgumentMethod · 0.95
testTruncateMethod · 0.95
bug801631Method · 0.95
testAppendMethod · 0.95
test_fileio_closefdMethod · 0.95

Calls 2

superClass · 0.85
closeMethod · 0.45

Tested by 12

testErrorsMethod · 0.76
testAblesMethod · 0.76
testUnicodeOpenMethod · 0.76
testBytesOpenMethod · 0.76
testUtf8BytesOpenMethod · 0.76
testBooleanFdMethod · 0.76
testBadModeArgumentMethod · 0.76
testTruncateMethod · 0.76
bug801631Method · 0.76
testAppendMethod · 0.76
test_fileio_closefdMethod · 0.76