~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/atomicfile.py

  • Committer: Martin Pool
  • Date: 2005-05-26 16:09:45 UTC
  • Revision ID: mbp@sourcefrog.net-20050526160945-7574594a45ba1c9c
- more invariant checks in AtomicFile

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
        if self.closed:
62
62
            raise Exception('%r is already closed' % self)
63
63
 
 
64
        self.closed = True
64
65
        self.f.close()
65
 
        self.closed = True
 
66
        self.f = None
 
67
        
66
68
        if sys.platform == 'win32':
67
69
            # windows cannot rename over an existing file
68
70
            try:
71
73
                import errno
72
74
                if e.errno != errno.ENOENT:
73
75
                    raise
 
76
                
74
77
        os.rename(self.tmpfilename, self.realfilename)
75
78
 
76
79
 
81
84
        if self.closed:
82
85
            raise Exception('%r is already closed' % self)
83
86
 
 
87
        self.closed = True
84
88
        self.f.close()
85
 
        self.closed = True
 
89
        self.f = None
86
90
        os.remove(self.tmpfilename)
87
91
 
88
92