Ticket #8175: close_open_trap.diff

File close_open_trap.diff, 580 bytes (added by magneto, 16 years ago)

try/except around the 'open' step in close()

  • django/core/files/base.py

     
    144144        self.file.flush()
    145145
    146146    def close(self):
    147         self.file.close()
     147        if self._closed:
     148            return
     149        try:
     150            if self.file:
     151                self.file.close()
     152        except IOError:
     153            #file is not there or went away .. so it's closed
     154            pass
    148155        self._closed = True
    149156
    150157class ContentFile(File):
Back to Top