diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/howto/urllib2.rst | 10 | ||||
-rw-r--r-- | Doc/lib/email-unpack.py | 2 | ||||
-rw-r--r-- | Doc/lib/libcsv.tex | 2 | ||||
-rw-r--r-- | Doc/lib/libgetopt.tex | 2 | ||||
-rw-r--r-- | Doc/lib/libshutil.tex | 2 | ||||
-rw-r--r-- | Doc/lib/libsocket.tex | 8 | ||||
-rw-r--r-- | Doc/lib/libsubprocess.tex | 2 | ||||
-rw-r--r-- | Doc/lib/libxdrlib.tex | 2 | ||||
-rw-r--r-- | Doc/lib/libxmlrpclib.tex | 2 | ||||
-rw-r--r-- | Doc/lib/sqlite3/complete_statement.py | 2 | ||||
-rwxr-xr-x | Doc/tools/findcsyms | 2 | ||||
-rwxr-xr-x | Doc/tools/listmodules | 2 | ||||
-rwxr-xr-x | Doc/tools/mkhowto | 2 | ||||
-rwxr-xr-x | Doc/tools/mksourcepkg | 2 | ||||
-rw-r--r-- | Doc/tools/prechm.py | 4 | ||||
-rwxr-xr-x | Doc/tools/sgmlconv/docfixer.py | 3 | ||||
-rwxr-xr-x | Doc/tools/sgmlconv/esis2sgml.py | 3 | ||||
-rw-r--r-- | Doc/tools/sgmlconv/esistools.py | 2 | ||||
-rwxr-xr-x | Doc/tools/sgmlconv/latex2esis.py | 3 | ||||
-rw-r--r-- | Doc/tut/tut.tex | 11 |
20 files changed, 36 insertions, 32 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst index 69ce508..858c9b1 100644 --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -214,7 +214,7 @@ e.g. :: >>> req = urllib2.Request('http://www.pretend_server.org') >>> try: urllib2.urlopen(req) - >>> except URLError, e: + >>> except URLError as e: >>> print e.reason >>> (4, 'getaddrinfo failed') @@ -326,7 +326,7 @@ attribute, it also has read, geturl, and info, methods. :: >>> req = urllib2.Request('http://www.python.org/fish.html') >>> try: >>> urllib2.urlopen(req) - >>> except URLError, e: + >>> except URLError as e: >>> print e.code >>> print e.read() >>> @@ -354,10 +354,10 @@ Number 1 req = Request(someurl) try: response = urlopen(req) - except HTTPError, e: + except HTTPError as e: print 'The server couldn\'t fulfill the request.' print 'Error code: ', e.code - except URLError, e: + except URLError as e: print 'We failed to reach a server.' print 'Reason: ', e.reason else: @@ -378,7 +378,7 @@ Number 2 req = Request(someurl) try: response = urlopen(req) - except URLError, e: + except URLError as e: if hasattr(e, 'reason'): print 'We failed to reach a server.' print 'Reason: ', e.reason diff --git a/Doc/lib/email-unpack.py b/Doc/lib/email-unpack.py index fb03e58..e596b98 100644 --- a/Doc/lib/email-unpack.py +++ b/Doc/lib/email-unpack.py @@ -35,7 +35,7 @@ Usage: %prog [options] msgfile try: os.mkdir(opts.directory) - except OSError, e: + except OSError as e: # Ignore directory exists error if e.errno != errno.EEXIST: raise diff --git a/Doc/lib/libcsv.tex b/Doc/lib/libcsv.tex index e965e31..b87bc9d 100644 --- a/Doc/lib/libcsv.tex +++ b/Doc/lib/libcsv.tex @@ -426,7 +426,7 @@ reader = csv.reader(open(filename, "rb")) try: for row in reader: print row -except csv.Error, e: +except csv.Error as e: sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e)) \end{verbatim} diff --git a/Doc/lib/libgetopt.tex b/Doc/lib/libgetopt.tex index b38fcd8..7930acd 100644 --- a/Doc/lib/libgetopt.tex +++ b/Doc/lib/libgetopt.tex @@ -126,7 +126,7 @@ import getopt, sys def main(): try: opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) - except getopt.GetoptError, err: + except getopt.GetoptError as err: # print help information and exit: print str(err) # will print something like "option -a not recognized" usage() diff --git a/Doc/lib/libshutil.tex b/Doc/lib/libshutil.tex index 449d741..3037e0b 100644 --- a/Doc/lib/libshutil.tex +++ b/Doc/lib/libshutil.tex @@ -144,6 +144,6 @@ def copytree(src, dst, symlinks=0): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) - except (IOError, os.error), why: + except (IOError, os.error) as why: print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) \end{verbatim} diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex index f20c56c..69877d3 100644 --- a/Doc/lib/libsocket.tex +++ b/Doc/lib/libsocket.tex @@ -813,13 +813,13 @@ for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM, af, socktype, proto, canonname, sa = res try: s = socket.socket(af, socktype, proto) - except socket.error, msg: + except socket.error as msg: s = None continue try: s.bind(sa) s.listen(1) - except socket.error, msg: + except socket.error as msg: s.close() s = None continue @@ -848,12 +848,12 @@ for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: s = socket.socket(af, socktype, proto) - except socket.error, msg: + except socket.error as msg: s = None continue try: s.connect(sa) - except socket.error, msg: + except socket.error as msg: s.close() s = None continue diff --git a/Doc/lib/libsubprocess.tex b/Doc/lib/libsubprocess.tex index f639710..cb30974 100644 --- a/Doc/lib/libsubprocess.tex +++ b/Doc/lib/libsubprocess.tex @@ -284,7 +284,7 @@ try: print >>sys.stderr, "Child was terminated by signal", -retcode else: print >>sys.stderr, "Child returned", retcode -except OSError, e: +except OSError as e: print >>sys.stderr, "Execution failed:", e \end{verbatim} diff --git a/Doc/lib/libxdrlib.tex b/Doc/lib/libxdrlib.tex index d0863d9..56474b7 100644 --- a/Doc/lib/libxdrlib.tex +++ b/Doc/lib/libxdrlib.tex @@ -246,6 +246,6 @@ import xdrlib p = xdrlib.Packer() try: p.pack_double(8.01) -except xdrlib.ConversionError, instance: +except xdrlib.ConversionError as instance: print 'packing the double failed:', instance.msg \end{verbatim} diff --git a/Doc/lib/libxmlrpclib.tex b/Doc/lib/libxmlrpclib.tex index c870d26..7af9e76 100644 --- a/Doc/lib/libxmlrpclib.tex +++ b/Doc/lib/libxmlrpclib.tex @@ -358,7 +358,7 @@ print server try: print server.examples.getStateName(41) -except Error, v: +except Error as v: print "ERROR", v \end{verbatim} diff --git a/Doc/lib/sqlite3/complete_statement.py b/Doc/lib/sqlite3/complete_statement.py index 22525e3..76ea7f6 100644 --- a/Doc/lib/sqlite3/complete_statement.py +++ b/Doc/lib/sqlite3/complete_statement.py @@ -23,7 +23,7 @@ while True: if buffer.lstrip().upper().startswith("SELECT"): print cur.fetchall() - except sqlite3.Error, e: + except sqlite3.Error as e: print "An error occurred:", e.args[0] buffer = "" diff --git a/Doc/tools/findcsyms b/Doc/tools/findcsyms index ac9b754..d68c3ce 100755 --- a/Doc/tools/findcsyms +++ b/Doc/tools/findcsyms @@ -127,7 +127,7 @@ def main(): print_list(undocumented, "Undocumented symbols") else: print_list(L) - except IOError, e: + except IOError as e: if e.errno != errno.EPIPE: raise diff --git a/Doc/tools/listmodules b/Doc/tools/listmodules index 03e7b5d..8469972 100755 --- a/Doc/tools/listmodules +++ b/Doc/tools/listmodules @@ -53,7 +53,7 @@ def main(): opts, args = getopt.getopt( args, "abchi:", ["annotate", "built-in", "categorize", "help", "ignore-from="]) - except getopt.error, msg: + except getopt.error as msg: sys.stdout = sys.stderr print msg print diff --git a/Doc/tools/mkhowto b/Doc/tools/mkhowto index 21cd6fb..02a215d 100755 --- a/Doc/tools/mkhowto +++ b/Doc/tools/mkhowto @@ -599,7 +599,7 @@ def main(): options = Options() try: args = options.parse(sys.argv[1:]) - except getopt.error, msg: + except getopt.error as msg: error(options, msg) if not args: # attempt to locate single .tex file in current directory: diff --git a/Doc/tools/mksourcepkg b/Doc/tools/mksourcepkg index 4b21f77..7d5bd73 100755 --- a/Doc/tools/mksourcepkg +++ b/Doc/tools/mksourcepkg @@ -45,7 +45,7 @@ def main(): opts, args = getopt.getopt(sys.argv[1:], "Aabgtzq", ["all", "bzip2", "gzip", "tools", "zip", "quiet", "anonymous"]) - except getopt.error, e: + except getopt.error as e: usage(warning=str(e)) sys.exit(2) if len(args) not in (1, 2): diff --git a/Doc/tools/prechm.py b/Doc/tools/prechm.py index 57a43fd..db1f965 100644 --- a/Doc/tools/prechm.py +++ b/Doc/tools/prechm.py @@ -448,7 +448,7 @@ def do_project(library, output, arch, version): def openfile(file): try: p = open(file, "w") - except IOError, msg: + except IOError as msg: print file, ":", msg sys.exit(1) return p @@ -466,7 +466,7 @@ def do_it(args = None): try: optlist, args = getopt.getopt(args, 'ckpv:') - except getopt.error, msg: + except getopt.error as msg: print msg usage() diff --git a/Doc/tools/sgmlconv/docfixer.py b/Doc/tools/sgmlconv/docfixer.py index 81519ee..961e3b8 100755 --- a/Doc/tools/sgmlconv/docfixer.py +++ b/Doc/tools/sgmlconv/docfixer.py @@ -1039,7 +1039,8 @@ def convert(ifp, ofp): # try: write_esis(fragment, ofp, knownempty) - except IOError, (err, msg): + except IOError as e: + (err, msg) = e # Ignore EPIPE; it just means that whoever we're writing to stopped # reading. The rest of the output would be ignored. All other errors # should still be reported, diff --git a/Doc/tools/sgmlconv/esis2sgml.py b/Doc/tools/sgmlconv/esis2sgml.py index b6f9a44..81294d1 100755 --- a/Doc/tools/sgmlconv/esis2sgml.py +++ b/Doc/tools/sgmlconv/esis2sgml.py @@ -255,7 +255,8 @@ def main(): if xml and xmldecl: opf.write('<?xml version="1.0" encoding="iso8859-1"?>\n') convert(ifp, ofp, xml=xml, autoclose=autoclose, verbatims=verbatims) - except IOError, (err, msg): + except IOError as e: + (err, msg) = e if err != errno.EPIPE: raise diff --git a/Doc/tools/sgmlconv/esistools.py b/Doc/tools/sgmlconv/esistools.py index 833fea1..6dc5eaa 100644 --- a/Doc/tools/sgmlconv/esistools.py +++ b/Doc/tools/sgmlconv/esistools.py @@ -139,7 +139,7 @@ class ESISReader(xml.sax.xmlreader.XMLReader): def _get_token(self, fp): try: line = fp.readline() - except IOError, e: + except IOError as e: e = SAXException("I/O error reading input stream", e) self.getErrorHandler().fatalError(e) return diff --git a/Doc/tools/sgmlconv/latex2esis.py b/Doc/tools/sgmlconv/latex2esis.py index 643ef2c..cbc9828 100755 --- a/Doc/tools/sgmlconv/latex2esis.py +++ b/Doc/tools/sgmlconv/latex2esis.py @@ -397,7 +397,8 @@ def convert(ifp, ofp, table): c = Conversion(ifp, ofp, table) try: c.convert() - except IOError, (err, msg): + except IOError as e: + (err, msg) = e if err != errno.EPIPE: raise diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index 4b6b93f..3ecc57f 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -3480,8 +3480,9 @@ try: f = open('myfile.txt') s = f.readline() i = int(s.strip()) -except IOError, (errno, strerror): - print "I/O error(%s): %s" % (errno, strerror) +except IOError as e: + (errno, strerror) = e + print "I/O error(%s): %s" % (e.errno, e.strerror) except ValueError: print "Could not convert data to an integer." except: @@ -3530,7 +3531,7 @@ as desired. \begin{verbatim} >>> try: ... raise Exception('spam', 'eggs') -... except Exception, inst: +... except Exception as inst: ... print type(inst) # the exception instance ... print inst.args # arguments stored in .args ... print inst # __str__ allows args to printed directly @@ -3559,7 +3560,7 @@ For example: ... >>> try: ... this_fails() -... except ZeroDivisionError, detail: +... except ZeroDivisionError as detail: ... print 'Handling run-time error:', detail ... Handling run-time error: integer division or modulo by zero @@ -3619,7 +3620,7 @@ example: ... >>> try: ... raise MyError(2*2) -... except MyError, e: +... except MyError as e: ... print 'My exception occurred, value:', e.value ... My exception occurred, value: 4 |