Mercurial > hg
comparison mercurial/util.py @ 8785:7a9151bc5b37
atomictempfile: fix exception in __del__ if mktempcopy fails (self._fp is None)
Make what is going on more obvious by explicitely getting the 'closed'
attribute from _fp, instead of from the gettatr proxy.
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 13 Jun 2009 13:14:02 +0200 |
parents | c5f36402daad |
children | 9b8c9266c59d |
comparison
equal
deleted
inserted
replaced
8784:9154c79c67cc | 8785:7a9151bc5b37 |
---|---|
765 | 765 |
766 def __getattr__(self, name): | 766 def __getattr__(self, name): |
767 return getattr(self._fp, name) | 767 return getattr(self._fp, name) |
768 | 768 |
769 def rename(self): | 769 def rename(self): |
770 if not self.closed: | 770 if not self._fp.closed: |
771 self._fp.close() | 771 self._fp.close() |
772 rename(self.temp, localpath(self.__name)) | 772 rename(self.temp, localpath(self.__name)) |
773 | 773 |
774 def __del__(self): | 774 def __del__(self): |
775 if not self.closed: | 775 if not self._fp: |
776 return | |
777 if not self._fp.closed: | |
776 try: | 778 try: |
777 os.unlink(self.temp) | 779 os.unlink(self.temp) |
778 except: pass | 780 except: pass |
779 if self._fp: | 781 self._fp.close() |
780 self._fp.close() | |
781 | 782 |
782 def makedirs(name, mode=None): | 783 def makedirs(name, mode=None): |
783 """recursive directory creation with parent mode inheritance""" | 784 """recursive directory creation with parent mode inheritance""" |
784 try: | 785 try: |
785 os.mkdir(name) | 786 os.mkdir(name) |