mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V" (b) V is now limited to a simple name (local variable) (c) V is now deleted at the end of the except block
This commit is contained in:
parent
893523e80a
commit
b940e113bf
295 changed files with 817 additions and 743 deletions
|
@ -258,7 +258,7 @@ class Maildir(Mailbox):
|
|||
os.remove(tmp_file.name)
|
||||
else:
|
||||
os.rename(tmp_file.name, dest)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
os.remove(tmp_file.name)
|
||||
if e.errno == errno.EEXIST:
|
||||
raise ExternalClashError('Name clash with existing message: %s'
|
||||
|
@ -280,7 +280,7 @@ class Maildir(Mailbox):
|
|||
self.remove(key)
|
||||
except KeyError:
|
||||
pass
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
|
||||
|
@ -437,12 +437,12 @@ class Maildir(Mailbox):
|
|||
path = os.path.join(self._path, 'tmp', uniq)
|
||||
try:
|
||||
os.stat(path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
Maildir._count += 1
|
||||
try:
|
||||
return _create_carefully(path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
else:
|
||||
|
@ -495,7 +495,7 @@ class _singlefileMailbox(Mailbox):
|
|||
Mailbox.__init__(self, path, factory, create)
|
||||
try:
|
||||
f = open(self._path, 'rb+')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
if create:
|
||||
f = open(self._path, 'wb+')
|
||||
|
@ -605,7 +605,7 @@ class _singlefileMailbox(Mailbox):
|
|||
self._file.close()
|
||||
try:
|
||||
os.rename(new_file.name, self._path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno == errno.EEXIST or \
|
||||
(os.name == 'os2' and e.errno == errno.EACCES):
|
||||
os.remove(self._path)
|
||||
|
@ -837,7 +837,7 @@ class MH(Mailbox):
|
|||
path = os.path.join(self._path, str(key))
|
||||
try:
|
||||
f = open(path, 'rb+')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
raise KeyError('No message with key: %s' % key)
|
||||
else:
|
||||
|
@ -859,7 +859,7 @@ class MH(Mailbox):
|
|||
path = os.path.join(self._path, str(key))
|
||||
try:
|
||||
f = open(path, 'rb+')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
raise KeyError('No message with key: %s' % key)
|
||||
else:
|
||||
|
@ -885,7 +885,7 @@ class MH(Mailbox):
|
|||
f = open(os.path.join(self._path, str(key)), 'r+')
|
||||
else:
|
||||
f = open(os.path.join(self._path, str(key)), 'r')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
raise KeyError('No message with key: %s' % key)
|
||||
else:
|
||||
|
@ -912,7 +912,7 @@ class MH(Mailbox):
|
|||
f = open(os.path.join(self._path, str(key)), 'r+')
|
||||
else:
|
||||
f = open(os.path.join(self._path, str(key)), 'r')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
raise KeyError('No message with key: %s' % key)
|
||||
else:
|
||||
|
@ -932,7 +932,7 @@ class MH(Mailbox):
|
|||
"""Return a file-like representation or raise a KeyError."""
|
||||
try:
|
||||
f = open(os.path.join(self._path, str(key)), 'rb')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
raise KeyError('No message with key: %s' % key)
|
||||
else:
|
||||
|
@ -1843,7 +1843,7 @@ def _lock_file(f, dotlock=True):
|
|||
if fcntl:
|
||||
try:
|
||||
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno in (errno.EAGAIN, errno.EACCES):
|
||||
raise ExternalClashError('lockf: lock unavailable: %s' %
|
||||
f.name)
|
||||
|
@ -1853,7 +1853,7 @@ def _lock_file(f, dotlock=True):
|
|||
try:
|
||||
pre_lock = _create_temporary(f.name + '.lock')
|
||||
pre_lock.close()
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.EACCES:
|
||||
return # Without write access, just skip dotlocking.
|
||||
else:
|
||||
|
@ -1866,7 +1866,7 @@ def _lock_file(f, dotlock=True):
|
|||
else:
|
||||
os.rename(pre_lock.name, f.name + '.lock')
|
||||
dotlock_done = True
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno == errno.EEXIST or \
|
||||
(os.name == 'os2' and e.errno == errno.EACCES):
|
||||
os.remove(pre_lock.name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue