diff options
author | Guido van Rossum <guido@python.org> | 2007-01-10 16:19:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-01-10 16:19:56 (GMT) |
commit | b940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (patch) | |
tree | 0b9ea19eba1e665dac95126c3140ac2bc36326ad /Lib/mailbox.py | |
parent | 893523e80a2003d4a630aafb84ba016e0070cbbd (diff) | |
download | cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.zip cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.gz cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.bz2 |
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
Diffstat (limited to 'Lib/mailbox.py')
-rwxr-xr-x | Lib/mailbox.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index 8d1df4b..2293a6c 100755 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -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) |