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/urllib.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/urllib.py')
-rw-r--r-- | Lib/urllib.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index 27ec2c9..aacc373 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -190,7 +190,7 @@ class URLopener: return getattr(self, name)(url) else: return getattr(self, name)(url, data) - except socket.error, msg: + except socket.error as msg: raise IOError, ('socket error', msg), sys.exc_info()[2] def open_unknown(self, fullurl, data=None): @@ -217,7 +217,7 @@ class URLopener: hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs - except IOError, msg: + except IOError as msg: pass fp = self.open(url, data) headers = fp.info() @@ -461,7 +461,7 @@ class URLopener: localname = url2pathname(file) try: stats = os.stat(localname) - except OSError, e: + except OSError as e: raise IOError(e.errno, e.strerror, e.filename) size = stats.st_size modified = email.Utils.formatdate(stats.st_mtime, usegmt=True) @@ -544,7 +544,7 @@ class URLopener: headers += "Content-Length: %d\n" % retrlen headers = mimetools.Message(StringIO(headers)) return addinfourl(fp, headers, "ftp:" + url) - except ftperrors(), msg: + except ftperrors() as msg: raise IOError, ('ftp error', msg), sys.exc_info()[2] def open_data(self, url, data=None): @@ -861,7 +861,7 @@ class ftpwrapper: try: cmd = 'RETR ' + file conn = self.ftp.ntransfercmd(cmd) - except ftplib.error_perm, reason: + except ftplib.error_perm as reason: if str(reason)[:3] != '550': raise IOError, ('ftp error', reason), sys.exc_info()[2] if not conn: @@ -1503,7 +1503,7 @@ def main(): import getopt, sys try: opts, args = getopt.getopt(sys.argv[1:], "th") - except getopt.error, msg: + except getopt.error as msg: print msg print "Use -h for help" return |