(self, exc_type, exc_val, exc_tb)
| 255 | return self.f |
| 256 | |
| 257 | def __exit__(self, exc_type, exc_val, exc_tb): |
| 258 | from .. import platform |
| 259 | |
| 260 | self.f.close() # this indirectly also closes self.tmp_fd |
| 261 | self.tmp_fd = None |
| 262 | if exc_type is not None: |
| 263 | safe_unlink(self.tmp_fname) # with-body has failed, clean up tmp file |
| 264 | return # continue processing the exception normally |
| 265 | |
| 266 | try: |
| 267 | os.replace(self.tmp_fname, self.path) # POSIX: atomic rename |
| 268 | except OSError: |
| 269 | safe_unlink(self.tmp_fname) # rename has failed, clean up tmp file |
| 270 | raise |
| 271 | finally: |
| 272 | platform.sync_dir(self.dir) |
| 273 | |
| 274 | |
| 275 | def swidth(s): |
nothing calls this directly
no test coverage detected