/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Jelmer Vernooij
  • Date: 2017-02-05 15:38:26 UTC
  • mto: (6621.2.1 py3)
  • mto: This revision was merged to the branch mainline in revision 6624.
  • Revision ID: jelmer@jelmer.uk-20170205153826-rnrd0m3iqoizqvrw
Apply 2to3 except fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
        try:
156
156
            self.f = open(self.filename, filemode)
157
157
            return self.f
158
 
        except IOError, e:
 
158
        except IOError as e:
159
159
            if e.errno in (errno.EACCES, errno.EPERM):
160
160
                raise errors.LockFailed(self.filename, str(e))
161
161
            if e.errno != errno.ENOENT:
217
217
                # LOCK_NB will cause IOError to be raised if we can't grab a
218
218
                # lock right away.
219
219
                fcntl.lockf(self.f, fcntl.LOCK_EX | fcntl.LOCK_NB)
220
 
            except IOError, e:
 
220
            except IOError as e:
221
221
                if e.errno in (errno.EAGAIN, errno.EACCES):
222
222
                    # We couldn't grab the lock
223
223
                    self.unlock()
252
252
                # LOCK_NB will cause IOError to be raised if we can't grab a
253
253
                # lock right away.
254
254
                fcntl.lockf(self.f, fcntl.LOCK_SH | fcntl.LOCK_NB)
255
 
            except IOError, e:
 
255
            except IOError as e:
256
256
                # we should be more precise about whats a locking
257
257
                # error and whats a random-other error
258
258
                raise errors.LockContention(self.filename, e)
313
313
            # done by _fcntl_ReadLock
314
314
            try:
315
315
                new_f = open(self.filename, 'rb+')
316
 
            except IOError, e:
 
316
            except IOError as e:
317
317
                if e.errno in (errno.EACCES, errno.EPERM):
318
318
                    raise errors.LockFailed(self.filename, str(e))
319
319
                raise
321
321
                # LOCK_NB will cause IOError to be raised if we can't grab a
322
322
                # lock right away.
323
323
                fcntl.lockf(new_f, fcntl.LOCK_EX | fcntl.LOCK_NB)
324
 
            except IOError, e:
 
324
            except IOError as e:
325
325
                # TODO: Raise a more specific error based on the type of error
326
326
                raise errors.LockContention(self.filename, e)
327
327
            _fcntl_WriteLock._open_locks.add(self.filename)
360
360
                self._handle = win32file_CreateFile(filename, access, share,
361
361
                    None, win32file.OPEN_ALWAYS,
362
362
                    win32file.FILE_ATTRIBUTE_NORMAL, None)
363
 
            except pywintypes.error, e:
 
363
            except pywintypes.error as e:
364
364
                if e.args[0] == winerror.ERROR_ACCESS_DENIED:
365
365
                    raise errors.LockFailed(filename, e)
366
366
                if e.args[0] == winerror.ERROR_SHARING_VIOLATION: