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

Method close

Lib/lzma.py:134–155  ·  view source on GitHub ↗

Flush and close the file. May be called more than once without error. Once the file is closed, any other operation on it will raise a ValueError.

(self)

Source from the content-addressed store, hash-verified

132 self._buffer = io.BufferedReader(raw)
133
134 def close(self):
135 """Flush and close the file.
136
137 May be called more than once without error. Once the file is
138 closed, any other operation on it will raise a ValueError.
139 """
140 if self.closed:
141 return
142 try:
143 if self._mode == _MODE_READ:
144 self._buffer.close()
145 self._buffer = None
146 elif self._mode == _MODE_WRITE:
147 self._fp.write(self._compressor.flush())
148 self._compressor = None
149 finally:
150 try:
151 if self._closefp:
152 self._fp.close()
153 finally:
154 self._fp = None
155 self._closefp = False
156
157 @property
158 def closed(self):

Callers 12

xzopenMethod · 0.95
test_closeMethod · 0.95
test_closedMethod · 0.95
test_filenoMethod · 0.95
test_seekableMethod · 0.95
test_readableMethod · 0.95
test_writableMethod · 0.95
test_read_bad_argsMethod · 0.95
test_read1_bad_argsMethod · 0.95
test_write_bad_argsMethod · 0.95
test_seek_bad_argsMethod · 0.95
test_tell_bad_argsMethod · 0.95

Calls 2

writeMethod · 0.45
flushMethod · 0.45

Tested by 11

test_closeMethod · 0.76
test_closedMethod · 0.76
test_filenoMethod · 0.76
test_seekableMethod · 0.76
test_readableMethod · 0.76
test_writableMethod · 0.76
test_read_bad_argsMethod · 0.76
test_read1_bad_argsMethod · 0.76
test_write_bad_argsMethod · 0.76
test_seek_bad_argsMethod · 0.76
test_tell_bad_argsMethod · 0.76