summaryrefslogtreecommitdiffstats
path: root/examples/painting/imagecomposition/imagecomposer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/painting/imagecomposition/imagecomposer.cpp')
-rw-r--r--examples/painting/imagecomposition/imagecomposer.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/examples/painting/imagecomposition/imagecomposer.cpp b/examples/painting/imagecomposition/imagecomposer.cpp
index d215d96..102152d 100644
--- a/examples/painting/imagecomposition/imagecomposer.cpp
+++ b/examples/painting/imagecomposition/imagecomposer.cpp
@@ -9,8 +9,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -21,20 +21,20 @@
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
** package.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
est_os.py | 2 +- Lib/test/test_ossaudiodev.py | 4 +-- Lib/test/test_parser.py | 2 +- Lib/test/test_pep277.py | 2 +- Lib/test/test_pyexpat.py | 6 ++-- Lib/test/test_re.py | 2 +- Lib/test/test_runpy.py | 8 ++--- Lib/test/test_sax.py | 2 +- Lib/test/test_set.py | 2 +- Lib/test/test_socket.py | 2 +- Lib/test/test_socket_ssl.py | 2 +- Lib/test/test_socketserver.py | 3 +- Lib/test/test_strftime.py | 4 +-- Lib/test/test_string.py | 2 +- Lib/test/test_strptime.py | 2 +- Lib/test/test_subprocess.py | 4 +-- Lib/test/test_sunaudiodev.py | 2 +- Lib/test/test_support.py | 3 +- Lib/test/test_syntax.py | 2 +- Lib/test/test_sys.py | 19 +++++------ Lib/test/test_tarfile.py | 2 +- Lib/test/test_tcl.py | 2 +- Lib/test/test_trace.py | 24 +++++++------- Lib/test/test_traceback.py | 2 +- Lib/test/test_urllib2net.py | 2 +- Lib/test/test_userdict.py | 6 ++-- Lib/test/test_uu.py | 4 +-- Lib/test/test_winreg.py | 2 +- Lib/timeit.py | 2 +- Lib/toaiff.py | 2 +- Lib/token.py | 6 ++-- Lib/trace.py | 12 +++---- Lib/unittest.py | 2 +- Lib/urllib.py | 12 +++---- Lib/urllib2.py | 6 ++-- Lib/uu.py | 2 +- Lib/warnings.py | 2 +- Lib/webbrowser.py | 2 +- Lib/xdrlib.py | 4 +-- Lib/xml/sax/__init__.py | 2 +- Lib/xml/sax/expatreader.py | 2 +- Lib/xmllib.py | 4 +-- Lib/xmlrpclib.py | 4 +-- Lib/zipfile.py | 2 +- Mac/BuildScript/build-installer.py | 2 +- Mac/Demo/applescript/makedisk.py | 2 +- Mac/Demo/imgbrowse/imgbrowse.py | 2 +- Mac/Demo/mlte/mlted.py | 2 +- Mac/Demo/resources/copyres.py | 2 +- Mac/Demo/textedit/ped.py | 2 +- Mac/scripts/BuildApplet.py | 2 +- Mac/scripts/buildpkg.py | 2 +- Misc/BeOS-setup.py | 2 +- Modules/parsermodule.c | 4 +-- Python/compile.c | 59 +++++++++++++++++++++++++++++++++-- Python/graminit.c | 2 +- Tools/audiopy/audiopy | 5 +-- Tools/bgen/bgen/scantools.py | 6 ++-- Tools/compiler/compile.py | 2 +- Tools/compiler/regrtest.py | 2 +- Tools/faqwiz/faqw.py | 2 +- Tools/faqwiz/faqwiz.py | 10 +++--- Tools/freeze/checkextensions_win32.py | 2 +- Tools/freeze/freeze.py | 8 ++--- Tools/i18n/msgfmt.py | 6 ++-- Tools/i18n/pygettext.py | 4 +-- Tools/pybench/CommandLine.py | 4 +-- Tools/pybench/pybench.py | 8 ++--- Tools/pynche/Main.py | 2 +- Tools/scripts/byext.py | 4 +-- Tools/scripts/byteyears.py | 2 +- Tools/scripts/checkappend.py | 6 ++-- Tools/scripts/classfix.py | 12 +++---- Tools/scripts/cleanfuture.py | 4 +-- Tools/scripts/cvsfiles.py | 2 +- Tools/scripts/dutree.py | 2 +- Tools/scripts/finddiv.py | 6 ++-- Tools/scripts/findlinksto.py | 2 +- Tools/scripts/findnocoding.py | 2 +- Tools/scripts/fixcid.py | 16 +++++----- Tools/scripts/fixdiv.py | 6 ++-- Tools/scripts/fixheader.py | 4 +-- Tools/scripts/fixnotice.py | 2 +- Tools/scripts/fixps.py | 2 +- Tools/scripts/ftpmirror.py | 20 ++++++------ Tools/scripts/linktree.py | 6 ++-- Tools/scripts/logmerge.py | 2 +- Tools/scripts/md5sum.py | 6 ++-- Tools/scripts/methfix.py | 12 +++---- Tools/scripts/ndiff.py | 4 +-- Tools/scripts/pathfix.py | 14 ++++----- Tools/scripts/pindent.py | 2 +- Tools/scripts/pysource.py | 6 ++-- Tools/scripts/redemo.py | 2 +- Tools/scripts/reindent.py | 4 +-- Tools/scripts/rgrep.py | 4 +-- Tools/scripts/texi2html.py | 10 +++--- Tools/scripts/treesync.py | 2 +- Tools/scripts/untabify.py | 4 +-- Tools/unicode/comparecodecs.py | 4 +-- Tools/unicode/gencodec.py | 6 ++-- Tools/unicode/listcodecs.py | 2 +- Tools/versioncheck/pyversioncheck.py | 2 +- Tools/webchecker/wcgui.py | 2 +- Tools/webchecker/webchecker.py | 10 +++--- Tools/webchecker/websucker.py | 4 +-- setup.py | 4 +-- 295 files changed, 817 insertions(+), 743 deletions(-) diff --git a/Demo/cgi/wiki.py b/Demo/cgi/wiki.py index ee094a8..2f944d6 100644 --- a/Demo/cgi/wiki.py +++ b/Demo/cgi/wiki.py @@ -119,5 +119,5 @@ class WikiPage: f.write('\n') f.close() return "" - except IOError, err: + except IOError as err: return "IOError: %s" % str(err) diff --git a/Demo/comparisons/regextest.py b/Demo/comparisons/regextest.py index b27d741..1fab052 100755 --- a/Demo/comparisons/regextest.py +++ b/Demo/comparisons/regextest.py @@ -28,7 +28,7 @@ def main(): for file in sys.argv[1:]: try: fp = open(file, 'r') - except IOError, msg: + except IOError as msg: print "%s: %s" % (file, msg) continue lineno = 0 diff --git a/Demo/comparisons/systemtest.py b/Demo/comparisons/systemtest.py index bbc313b..d3fc72b 100755 --- a/Demo/comparisons/systemtest.py +++ b/Demo/comparisons/systemtest.py @@ -41,7 +41,7 @@ def main(): def reportboguslinks(prefix): try: names = os.listdir('.') - except os.error, msg: + except os.error as msg: print "%s%s: can't list: %s" % (prefix, '.', msg) return names.sort() @@ -62,7 +62,7 @@ def reportboguslinks(prefix): elif S_ISDIR(mode): try: os.chdir(name) - except os.error, msg: + except os.error as msg: print "%s%s: can't chdir: %s" % \ (prefix, name, msg) continue diff --git a/Demo/parser/test_parser.py b/Demo/parser/test_parser.py index be39bca..1589f3b 100755 --- a/Demo/parser/test_parser.py +++ b/Demo/parser/test_parser.py @@ -17,7 +17,7 @@ def testChunk(t, fileName): # against a large source file like Tkinter.py. ast = None new = parser.tuple2ast(tup) - except parser.ParserError, err: + except parser.ParserError as err: print print 'parser module raised exception on input file', fileName + ':' traceback.print_exc() diff --git a/Demo/parser/unparse.py b/Demo/parser/unparse.py index 32acbed..1c6e933 100644 --- a/Demo/parser/unparse.py +++ b/Demo/parser/unparse.py @@ -492,7 +492,7 @@ def testdir(a): print 'Testing %s' % fullname try: roundtrip(fullname, output) - except Exception, e: + except Exception as e: print ' Failed to compile, exception is %s' % repr(e) elif os.path.isdir(fullname): testdir(fullname) diff --git a/Demo/pdist/FSProxy.py b/Demo/pdist/FSProxy.py index a1ab635..dad4015 100755 --- a/Demo/pdist/FSProxy.py +++ b/Demo/pdist/FSProxy.py @@ -87,7 +87,7 @@ class FSProxyLocal: fs = macfs.FSSpec(name) c, t = fs.GetCreatorType() if t != 'TEXT': return 0 - except macfs.error, msg: + except macfs.error as msg: print "***", name, msg return 0 else: diff --git a/Demo/pdist/cmdfw.py b/Demo/pdist/cmdfw.py index e2edd0a..47d13bc 100755 --- a/Demo/pdist/cmdfw.py +++ b/Demo/pdist/cmdfw.py @@ -42,7 +42,7 @@ class CommandFrameWork: if args is None: args = sys.argv[1:] try: opts, args = getopt.getopt(args, self.GlobalFlags) - except getopt.error, msg: + except getopt.error as msg: return self.usage(msg) self.options(opts) if not args: @@ -62,7 +62,7 @@ class CommandFrameWork: flags = '' try: opts, args = getopt.getopt(args[1:], flags) - except getopt.error, msg: + except getopt.error as msg: return self.usage( "subcommand %s: " % cmd + str(msg)) self.ready() diff --git a/Demo/pdist/cmptree.py b/Demo/pdist/cmptree.py index fa06f5f..5031869 100755 --- a/Demo/pdist/cmptree.py +++ b/Demo/pdist/cmptree.py @@ -135,7 +135,7 @@ def compare(local, remote, mode): def sendfile(local, remote, name): try: remote.create(name) - except (IOError, os.error), msg: + except (IOError, os.error) as msg: print "cannot create:", msg return @@ -171,7 +171,7 @@ def recvfile(local, remote, name): def recvfile_real(local, remote, name): try: local.create(name) - except (IOError, os.error), msg: + except (IOError, os.error) as msg: print "cannot create:", msg return diff --git a/Demo/pdist/cvslock.py b/Demo/pdist/cvslock.py index 8f6d008..6484e71 100755 --- a/Demo/pdist/cvslock.py +++ b/Demo/pdist/cvslock.py @@ -129,7 +129,7 @@ class Lock: self.lockdir = self.cvslck os.mkdir(self.cvslck, 0777) return - except os.error, msg: + except os.error as msg: self.lockdir = None if msg[0] == EEXIST: try: @@ -234,7 +234,7 @@ def MultipleWriteLock(repositories, delay = DELAY): for r in repositories: try: locks.append(WriteLock(r, 0)) - except Locked, instance: + except Locked as instance: del locks break else: diff --git a/Demo/pdist/rrcs.py b/Demo/pdist/rrcs.py index 4d23e6c..540d296 100755 --- a/Demo/pdist/rrcs.py +++ b/Demo/pdist/rrcs.py @@ -22,7 +22,7 @@ def main(): raise getopt.error, "unknown command" coptset, func = commands[cmd] copts, files = getopt.getopt(rest, coptset) - except getopt.error, msg: + except getopt.error as msg: print msg print "usage: rrcs [options] command [options] [file] ..." print "where command can be:" @@ -41,7 +41,7 @@ def main(): for fn in files: try: func(x, copts, fn) - except (IOError, os.error), msg: + except (IOError, os.error) as msg: print "%s: %s" % (fn, msg) def checkin(x, copts, fn): diff --git a/Demo/pysvr/pysvr.py b/Demo/pysvr/pysvr.py index 3b692b3..b1b7565 100755 --- a/Demo/pysvr/pysvr.py +++ b/Demo/pysvr/pysvr.py @@ -21,14 +21,14 @@ def main(): opts, args = getopt.getopt(sys.argv[1:], "") if len(args) > 1: raise getopt.error, "Too many arguments." - except getopt.error, msg: + except getopt.error as msg: usage(msg) for o, a in opts: pass if args: try: port = string.atoi(args[0]) - except ValueError, msg: + except ValueError as msg: usage(msg) else: port = PORT @@ -83,7 +83,7 @@ def run_interpreter(stdin, stdout): source = source + line try: code = compile_command(source) - except SyntaxError, err: + except SyntaxError as err: source = "" traceback.print_exception(SyntaxError, err, None, file=stdout) continue @@ -92,7 +92,7 @@ def run_interpreter(stdin, stdout): source = "" try: run_command(code, stdin, stdout, globals) - except SystemExit, how: + except SystemExit as how: if how: try: how = str(how) @@ -109,7 +109,7 @@ def run_command(code, stdin, stdout, globals): sys.stdin = stdin try: exec(code, globals) - except SystemExit, how: + except SystemExit as how: raise SystemExit, how, sys.exc_info()[2] except: type, value, tb = sys.exc_info() diff --git a/Demo/rpc/nfsclient.py b/Demo/rpc/nfsclient.py index 8e5a199..3890aff 100644 --- a/Demo/rpc/nfsclient.py +++ b/Demo/rpc/nfsclient.py @@ -194,8 +194,7 @@ def test(): fh = sf[1] if fh: ncl = NFSClient(host) - as = ncl.Getattr(fh) - print as + print ncl.Getattr(fh) list = ncl.Listdir(fh) for item in list: print item mcl.Umnt(filesys) diff --git a/Demo/rpc/rpc.py b/Demo/rpc/rpc.py index 141fe09..f7231c1 100644 --- a/Demo/rpc/rpc.py +++ b/Demo/rpc/rpc.py @@ -330,7 +330,8 @@ def bindresvport(sock, host): try: sock.bind((host, i)) return last_resv_port_tried - except socket.error, (errno, msg): + except socket.error as e: + (errno, msg) = e if errno != 114: raise socket.error, (errno, msg) raise RuntimeError, 'can\'t assign reserved port' @@ -765,7 +766,7 @@ class TCPServer(Server): call = recvrecord(sock) except EOFError: break - except socket.error, msg: + except socket.error as msg: print 'socket error:', msg break reply = self.handle(call) @@ -866,7 +867,7 @@ def testsvr(): s = S('', 0x20000000, 1, 0) try: s.unregister() - except RuntimeError, msg: + except RuntimeError as msg: print 'RuntimeError:', msg, '(ignored)' s.register() print 'Service started...' diff --git a/Demo/scripts/eqfix.py b/Demo/scripts/eqfix.py index 35c43aa..497ab20 100755 --- a/Demo/scripts/eqfix.py +++ b/Demo/scripts/eqfix.py @@ -62,7 +62,7 @@ def recursedown(dirname): bad = 0 try: names = os.listdir(dirname) - except os.error, msg: + except os.error as msg: err('%s: cannot list directory: %r\n' % (dirname, msg)) return 1 names.sort() @@ -83,7 +83,7 @@ def fix(filename): ## dbg('fix(%r)\n' % (dirname,)) try: f = open(filename, 'r') - except IOError, msg: + except IOError as msg: err('%s: cannot open: %r\n' % (filename, msg)) return 1 head, tail = os.path.split(filename) @@ -120,7 +120,7 @@ def fix(filename): if g is None: try: g = open(tempname, 'w') - except IOError, msg: + except IOError as msg: f.close() err('%s: cannot create: %r\n' % (tempname, msg)) return 1 @@ -144,17 +144,17 @@ def fix(filename): try: statbuf = os.stat(filename) os.chmod(tempname, statbuf[ST_MODE] & 07777) - except os.error, msg: + except os.error as msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ try: os.rename(filename, filename + '~') - except os.error, msg: + except os.error as msg: err('%s: warning: backup failed (%r)\n' % (filename, msg)) # Now move the temp file to the original file try: os.rename(tempname, filename) - except os.error, msg: + except os.error as msg: err('%s: rename failed (%r)\n' % (filename, msg)) return 1 # Return succes diff --git a/Demo/scripts/ftpstats.py b/Demo/scripts/ftpstats.py index 5c1599e..c7c0749 100755 --- a/Demo/scripts/ftpstats.py +++ b/Demo/scripts/ftpstats.py @@ -25,7 +25,7 @@ def main(): search = None try: opts, args = getopt.getopt(sys.argv[1:], 'm:s:') - except getopt.error, msg: + except getopt.error as msg: print msg print 'usage: ftpstats [-m maxitems] [file]' sys.exit(2) @@ -41,7 +41,7 @@ def main(): else: try: f = open(file, 'r') - except IOError, msg: + except IOError as msg: print file, ':', msg sys.exit(1) bydate = {} diff --git a/Demo/scripts/mboxconvert.py b/Demo/scripts/mboxconvert.py index 8c462f3..8da37bf 100755 --- a/Demo/scripts/mboxconvert.py +++ b/Demo/scripts/mboxconvert.py @@ -16,7 +16,7 @@ def main(): dofile = mmdf try: opts, args = getopt.getopt(sys.argv[1:], 'f') - except getopt.error, msg: + except getopt.error as msg: sys.stderr.write('%s\n' % msg) sys.exit(2) for o, a in opts: @@ -33,7 +33,7 @@ def main(): elif os.path.isfile(arg): try: f = open(arg) - except IOError, msg: + except IOError as msg: sys.stderr.write('%s: %s\n' % (arg, msg)) sts = 1 continue @@ -56,7 +56,7 @@ def mh(dir): fn = os.path.join(dir, msg) try: f = open(fn) - except IOError, msg: + except IOError as msg: sys.stderr.write('%s: %s\n' % (fn, msg)) sts = 1 continue diff --git a/Demo/scripts/newslist.py b/Demo/scripts/newslist.py index a631214..0111ace 100755 --- a/Demo/scripts/newslist.py +++ b/Demo/scripts/newslist.py @@ -330,7 +330,7 @@ def main(): else: s = NNTP(newshost) connected = 1 - except (nntplib.error_temp, nntplib.error_perm), x: + except (nntplib.error_temp, nntplib.error_perm) as x: print 'Error connecting to host:', x print 'I\'ll try to use just the local list.' connected = 0 diff --git a/Demo/scripts/pp.py b/Demo/scripts/pp.py index 0491fa9..2530ea3 100755 --- a/Demo/scripts/pp.py +++ b/Demo/scripts/pp.py @@ -35,7 +35,7 @@ PFLAG = 0 try: optlist, ARGS = getopt.getopt(sys.argv[1:], 'acde:F:np') -except getopt.error, msg: +except getopt.error as msg: sys.stderr.write(sys.argv[0] + ': ' + msg + '\n') sys.exit(2) diff --git a/Demo/scripts/update.py b/Demo/scripts/update.py index eac1a22..a965e4a 100755 --- a/Demo/scripts/update.py +++ b/Demo/scripts/update.py @@ -19,7 +19,7 @@ class FileObj: self.changed = 0 try: self.lines = open(filename, 'r').readlines() - except IOError, msg: + except IOError as msg: print '*** Can\'t open "%s":' % filename, msg self.lines = None return @@ -32,7 +32,7 @@ class FileObj: try: os.rename(self.filename, self.filename + '~') fp = open(self.filename, 'w') - except (os.error, IOError), msg: + except (os.error, IOError) as msg: print '*** Can\'t rewrite "%s":' % self.filename, msg return print 'writing', self.filename @@ -67,7 +67,7 @@ def main(): if sys.argv[1:]: try: fp = open(sys.argv[1], 'r') - except IOError, msg: + except IOError as msg: print 'Can\'t open "%s":' % sys.argv[1], msg sys.exit(1) else: diff --git a/Demo/sockets/gopher.py b/Demo/sockets/gopher.py index 2c46da6..0635ac1 100755 --- a/Demo/sockets/gopher.py +++ b/Demo/sockets/gopher.py @@ -142,7 +142,7 @@ def browser(*args): raise RuntimeError, 'too many args' try: browse_menu(selector, host, port) - except socket.error, msg: + except socket.error as msg: print 'Socket error:', msg sys.exit(1) except KeyboardInterrupt: @@ -202,7 +202,7 @@ def browse_textfile(selector, host, port): p = os.popen('${PAGER-more}', 'w') x = SaveLines(p) get_alt_textfile(selector, host, port, x.writeln) - except IOError, msg: + except IOError as msg: print 'IOError:', msg if x: x.close() @@ -213,7 +213,7 @@ def browse_textfile(selector, host, port): try: get_alt_textfile(selector, host, port, x.writeln) print 'Done.' - except IOError, msg: + except IOError as msg: print 'IOError:', msg x.close() @@ -311,7 +311,7 @@ def open_savefile(): cmd = savefile[1:].strip() try: p = os.popen(cmd, 'w') - except IOError, msg: + except IOError as msg: print repr(cmd), ':', msg return None print 'Piping through', repr(cmd), '...' @@ -320,7 +320,7 @@ def open_savefile(): savefile = os.path.expanduser(savefile) try: f = open(savefile, 'w') - except IOError, msg: + except IOError as msg: print repr(savefile), ':', msg return None print 'Saving to', repr(savefile), '...' diff --git a/Demo/sockets/telnet.py b/Demo/sockets/telnet.py index d50c37f..6bc9bcc 100755 --- a/Demo/sockets/telnet.py +++ b/Demo/sockets/telnet.py @@ -52,7 +52,7 @@ def main(): # try: s.connect((host, port)) - except error, msg: + except error as msg: sys.stderr.write('connect failed: ' + repr(msg) + '\n') sys.exit(1) # diff --git a/Demo/threads/find.py b/Demo/threads/find.py index 14148b8..68ca155 100644 --- a/Demo/threads/find.py +++ b/Demo/threads/find.py @@ -131,7 +131,7 @@ def selector(dir, name, fullname, stat): def find(dir, pred, wq): try: names = os.listdir(dir) - except os.error, msg: + except os.error as msg: print repr(dir), ':', msg return for name in names: @@ -139,7 +139,7 @@ def find(dir, pred, wq): fullname = os.path.join(dir, name) try: stat = os.lstat(fullname) - except os.error, msg: + except os.error as msg: print repr(fullname), ':', msg continue if pred(dir, name, fullname, stat): diff --git a/Demo/threads/telnet.py b/Demo/threads/telnet.py index 707a353..09f3bd9 100644 --- a/Demo/threads/telnet.py +++ b/Demo/threads/telnet.py @@ -56,7 +56,7 @@ def main(): # try: s.connect((host, port)) - except error, msg: + except error as msg: sys.stderr.write('connect failed: %r\n' % (msg,)) sys.exit(1) # diff --git a/Demo/tkinter/guido/AttrDialog.py b/Demo/tkinter/guido/AttrDialog.py index 9fa699e..d8b2571 100755 --- a/Demo/tkinter/guido/AttrDialog.py +++ b/Demo/tkinter/guido/AttrDialog.py @@ -156,7 +156,7 @@ class PackDialog(Dialog): self.current = self.var.get() try: self.dialog.widget.pack(**{self.option: self.current}) - except TclError, msg: + except TclError as msg: print msg self.refresh() @@ -212,7 +212,7 @@ class RemotePackDialog(PackDialog): 'pack', 'info', self.widget)) - except TclError, msg: + except TclError as msg: print msg return dict = {} @@ -239,7 +239,7 @@ class RemotePackDialog(PackDialog): '-'+self.option, self.dialog.master.tk.merge( self.current)) - except TclError, msg: + except TclError as msg: print msg self.refresh() @@ -285,7 +285,7 @@ class WidgetDialog(Dialog): self.current = self.var.get() try: self.dialog.widget[self.option] = self.current - except TclError, msg: + except TclError as msg: print msg self.refresh() @@ -374,7 +374,7 @@ class RemoteWidgetDialog(WidgetDialog): self.master.send(self.app, self.widget, 'config')) - except TclError, msg: + except TclError as msg: print msg return dict = {} @@ -398,7 +398,7 @@ class RemoteWidgetDialog(WidgetDialog): 'config', '-'+self.option, self.current) - except TclError, msg: + except TclError as msg: print msg self.refresh() @@ -445,7 +445,7 @@ def opendialogs(e): if widget == '.': continue try: RemotePackDialog(list, list.app, widget) - except TclError, msg: + except TclError as msg: print msg test() diff --git a/Demo/tkinter/guido/ManPage.py b/Demo/tkinter/guido/ManPage.py index 221af88..b189b64 100755 --- a/Demo/tkinter/guido/ManPage.py +++ b/Demo/tkinter/guido/ManPage.py @@ -95,7 +95,7 @@ class EditableManPage(ScrolledText): self._parseline('') try: self.tk.deletefilehandler(self.fp) - except TclError, msg: + except TclError as msg: pass self.fp.close() self.fp = None diff --git a/Demo/tkinter/guido/mbox.py b/Demo/tkinter/guido/mbox.py index 3c36d88..47c38b9 100755 --- a/Demo/tkinter/guido/mbox.py +++ b/Demo/tkinter/guido/mbox.py @@ -27,7 +27,7 @@ def main(): seq = 'all' try: opts, args = getopt.getopt(sys.argv[1:], '') - except getopt.error, msg: + except getopt.error as msg: print msg sys.exit(2) for arg in args: diff --git a/Demo/tkinter/guido/tkman.py b/Demo/tkinter/guido/tkman.py index 6b0b641..810bdf8 100755 --- a/Demo/tkinter/guido/tkman.py +++ b/Demo/tkinter/guido/tkman.py @@ -216,7 +216,7 @@ class SelectionBox: prog = re.compile(search, map) else: prog = re.compile(search) - except re.error, msg: + except re.error as msg: self.frame.bell() print 'Regex error:', msg return diff --git a/Demo/tkinter/guido/wish.py b/Demo/tkinter/guido/wish.py index 35e012c..2367e25 100755 --- a/Demo/tkinter/guido/wish.py +++ b/Demo/tkinter/guido/wish.py @@ -23,7 +23,7 @@ while 1: tk.record(line) try: result = tk.call('eval', cmd) - except _tkinter.TclError, msg: + except _tkinter.TclError as msg: print 'TclError:', msg else: if result: print result 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('\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 diff --git a/Grammar/Grammar b/Grammar/Grammar index 04ed68f..701a1ff 100644 --- a/Grammar/Grammar +++ b/Grammar/Grammar @@ -79,7 +79,7 @@ try_stmt: ('try' ':' suite with_stmt: 'with' test [ with_var ] ':' suite with_var: 'as' expr # NB compile.c makes sure that the default except clause is last -except_clause: 'except' [test [',' test]] +except_clause: 'except' [test ['as' test]] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT # Backward compatibility cruft to support: diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py index c119c9a..ce942ef 100644 --- a/Lib/CGIHTTPServer.py +++ b/Lib/CGIHTTPServer.py @@ -320,7 +320,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): sys.stdout = save_stdout sys.stderr = save_stderr os.chdir(save_cwd) - except SystemExit, sts: + except SystemExit as sts: self.log_error("CGI script exit status %s", str(sts)) else: self.log_message("CGI script exi