| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f48ef31 commit 8a01ec4
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -479,20 +479,15 @@ def write(self): | |||
| 479 | 479 | is_file_lock = isinstance(fp, string_types + (FileType, )) | |
| 480 | 480 | if is_file_lock: | |
| 481 | 481 | self._lock._obtain_lock() | |
| 482 | - try: | ||
| 483 | - if not hasattr(fp, "seek"): | ||
| 484 | - with open(self._file_or_files, "wb") as fp: | ||
| 485 | - self._write(fp) | ||
| 486 | - else: | ||
| 487 | - fp.seek(0) | ||
| 488 | - # make sure we do not overwrite into an existing file | ||
| 489 | - if hasattr(fp, 'truncate'): | ||
| 490 | - fp.truncate() | ||
| 482 | + if not hasattr(fp, "seek"): | ||
| 483 | + with open(self._file_or_files, "wb") as fp: | ||
| 491 | 484 | self._write(fp) | |
| 492 | - finally: | ||
| 493 | - # we release the lock - it will not vanish automatically in PY3.5+ | ||
| 494 | - if is_file_lock: | ||
| 495 | - self._lock._release_lock() | ||
| 485 | + else: | ||
| 486 | + fp.seek(0) | ||
| 487 | + # make sure we do not overwrite into an existing file | ||
| 488 | + if hasattr(fp, 'truncate'): | ||
| 489 | + fp.truncate() | ||
| 490 | + self._write(fp) | ||
| 496 | 491 | ||
| 497 | 492 | def _assure_writable(self, method_name): | |
| 498 | 493 | if self.read_only: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments