mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +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
				
			
		| 
						 | 
					@ -119,5 +119,5 @@ def store(self):
 | 
				
			||||||
                f.write('\n')
 | 
					                f.write('\n')
 | 
				
			||||||
            f.close()
 | 
					            f.close()
 | 
				
			||||||
            return ""
 | 
					            return ""
 | 
				
			||||||
        except IOError, err:
 | 
					        except IOError as err:
 | 
				
			||||||
            return "IOError: %s" % str(err)
 | 
					            return "IOError: %s" % str(err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ def main():
 | 
				
			||||||
    for file in sys.argv[1:]:
 | 
					    for file in sys.argv[1:]:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            fp = open(file, 'r')
 | 
					            fp = open(file, 'r')
 | 
				
			||||||
        except IOError, msg:
 | 
					        except IOError as msg:
 | 
				
			||||||
            print "%s: %s" % (file, msg)
 | 
					            print "%s: %s" % (file, msg)
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
        lineno = 0
 | 
					        lineno = 0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ def main():
 | 
				
			||||||
def reportboguslinks(prefix):
 | 
					def reportboguslinks(prefix):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        names = os.listdir('.')
 | 
					        names = os.listdir('.')
 | 
				
			||||||
    except os.error, msg:
 | 
					    except os.error as msg:
 | 
				
			||||||
        print "%s%s: can't list: %s" % (prefix, '.', msg)
 | 
					        print "%s%s: can't list: %s" % (prefix, '.', msg)
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
    names.sort()
 | 
					    names.sort()
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,7 @@ def reportboguslinks(prefix):
 | 
				
			||||||
        elif S_ISDIR(mode):
 | 
					        elif S_ISDIR(mode):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                os.chdir(name)
 | 
					                os.chdir(name)
 | 
				
			||||||
            except os.error, msg:
 | 
					            except os.error as msg:
 | 
				
			||||||
                print "%s%s: can't chdir: %s" % \
 | 
					                print "%s%s: can't chdir: %s" % \
 | 
				
			||||||
                      (prefix, name, msg)
 | 
					                      (prefix, name, msg)
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ def testChunk(t, fileName):
 | 
				
			||||||
        # against a large source file like Tkinter.py.
 | 
					        # against a large source file like Tkinter.py.
 | 
				
			||||||
        ast = None
 | 
					        ast = None
 | 
				
			||||||
        new = parser.tuple2ast(tup)
 | 
					        new = parser.tuple2ast(tup)
 | 
				
			||||||
    except parser.ParserError, err:
 | 
					    except parser.ParserError as err:
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        print 'parser module raised exception on input file', fileName + ':'
 | 
					        print 'parser module raised exception on input file', fileName + ':'
 | 
				
			||||||
        traceback.print_exc()
 | 
					        traceback.print_exc()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -492,7 +492,7 @@ def testdir(a):
 | 
				
			||||||
                print 'Testing %s' % fullname
 | 
					                print 'Testing %s' % fullname
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    roundtrip(fullname, output)
 | 
					                    roundtrip(fullname, output)
 | 
				
			||||||
                except Exception, e:
 | 
					                except Exception as e:
 | 
				
			||||||
                    print '  Failed to compile, exception is %s' % repr(e)
 | 
					                    print '  Failed to compile, exception is %s' % repr(e)
 | 
				
			||||||
            elif os.path.isdir(fullname):
 | 
					            elif os.path.isdir(fullname):
 | 
				
			||||||
                testdir(fullname)
 | 
					                testdir(fullname)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,7 +87,7 @@ def visible(self, name):
 | 
				
			||||||
                    fs = macfs.FSSpec(name)
 | 
					                    fs = macfs.FSSpec(name)
 | 
				
			||||||
                    c, t = fs.GetCreatorType()
 | 
					                    c, t = fs.GetCreatorType()
 | 
				
			||||||
                    if t != 'TEXT': return 0
 | 
					                    if t != 'TEXT': return 0
 | 
				
			||||||
                except macfs.error, msg:
 | 
					                except macfs.error as msg:
 | 
				
			||||||
                    print "***", name, msg
 | 
					                    print "***", name, msg
 | 
				
			||||||
                    return 0
 | 
					                    return 0
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ def run(self, args = None):
 | 
				
			||||||
        if args is None: args = sys.argv[1:]
 | 
					        if args is None: args = sys.argv[1:]
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            opts, args = getopt.getopt(args, self.GlobalFlags)
 | 
					            opts, args = getopt.getopt(args, self.GlobalFlags)
 | 
				
			||||||
        except getopt.error, msg:
 | 
					        except getopt.error as msg:
 | 
				
			||||||
            return self.usage(msg)
 | 
					            return self.usage(msg)
 | 
				
			||||||
        self.options(opts)
 | 
					        self.options(opts)
 | 
				
			||||||
        if not args:
 | 
					        if not args:
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,7 @@ def run(self, args = None):
 | 
				
			||||||
                flags = ''
 | 
					                flags = ''
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                opts, args = getopt.getopt(args[1:], flags)
 | 
					                opts, args = getopt.getopt(args[1:], flags)
 | 
				
			||||||
            except getopt.error, msg:
 | 
					            except getopt.error as msg:
 | 
				
			||||||
                return self.usage(
 | 
					                return self.usage(
 | 
				
			||||||
                        "subcommand %s: " % cmd + str(msg))
 | 
					                        "subcommand %s: " % cmd + str(msg))
 | 
				
			||||||
            self.ready()
 | 
					            self.ready()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,7 +135,7 @@ def compare(local, remote, mode):
 | 
				
			||||||
def sendfile(local, remote, name):
 | 
					def sendfile(local, remote, name):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        remote.create(name)
 | 
					        remote.create(name)
 | 
				
			||||||
    except (IOError, os.error), msg:
 | 
					    except (IOError, os.error) as msg:
 | 
				
			||||||
        print "cannot create:", msg
 | 
					        print "cannot create:", msg
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -171,7 +171,7 @@ def recvfile(local, remote, name):
 | 
				
			||||||
def recvfile_real(local, remote, name):
 | 
					def recvfile_real(local, remote, name):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        local.create(name)
 | 
					        local.create(name)
 | 
				
			||||||
    except (IOError, os.error), msg:
 | 
					    except (IOError, os.error) as msg:
 | 
				
			||||||
        print "cannot create:", msg
 | 
					        print "cannot create:", msg
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -129,7 +129,7 @@ def setlockdir(self):
 | 
				
			||||||
                self.lockdir = self.cvslck
 | 
					                self.lockdir = self.cvslck
 | 
				
			||||||
                os.mkdir(self.cvslck, 0777)
 | 
					                os.mkdir(self.cvslck, 0777)
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
            except os.error, msg:
 | 
					            except os.error as msg:
 | 
				
			||||||
                self.lockdir = None
 | 
					                self.lockdir = None
 | 
				
			||||||
                if msg[0] == EEXIST:
 | 
					                if msg[0] == EEXIST:
 | 
				
			||||||
                    try:
 | 
					                    try:
 | 
				
			||||||
| 
						 | 
					@ -234,7 +234,7 @@ def MultipleWriteLock(repositories, delay = DELAY):
 | 
				
			||||||
        for r in repositories:
 | 
					        for r in repositories:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                locks.append(WriteLock(r, 0))
 | 
					                locks.append(WriteLock(r, 0))
 | 
				
			||||||
            except Locked, instance:
 | 
					            except Locked as instance:
 | 
				
			||||||
                del locks
 | 
					                del locks
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ def main():
 | 
				
			||||||
            raise getopt.error, "unknown command"
 | 
					            raise getopt.error, "unknown command"
 | 
				
			||||||
        coptset, func = commands[cmd]
 | 
					        coptset, func = commands[cmd]
 | 
				
			||||||
        copts, files = getopt.getopt(rest, coptset)
 | 
					        copts, files = getopt.getopt(rest, coptset)
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
        print "usage: rrcs [options] command [options] [file] ..."
 | 
					        print "usage: rrcs [options] command [options] [file] ..."
 | 
				
			||||||
        print "where command can be:"
 | 
					        print "where command can be:"
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ def main():
 | 
				
			||||||
    for fn in files:
 | 
					    for fn in files:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            func(x, copts, fn)
 | 
					            func(x, copts, fn)
 | 
				
			||||||
        except (IOError, os.error), msg:
 | 
					        except (IOError, os.error) as msg:
 | 
				
			||||||
            print "%s: %s" % (fn, msg)
 | 
					            print "%s: %s" % (fn, msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def checkin(x, copts, fn):
 | 
					def checkin(x, copts, fn):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,14 +21,14 @@ def main():
 | 
				
			||||||
        opts, args = getopt.getopt(sys.argv[1:], "")
 | 
					        opts, args = getopt.getopt(sys.argv[1:], "")
 | 
				
			||||||
        if len(args) > 1:
 | 
					        if len(args) > 1:
 | 
				
			||||||
            raise getopt.error, "Too many arguments."
 | 
					            raise getopt.error, "Too many arguments."
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        usage(msg)
 | 
					        usage(msg)
 | 
				
			||||||
    for o, a in opts:
 | 
					    for o, a in opts:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
    if args:
 | 
					    if args:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            port = string.atoi(args[0])
 | 
					            port = string.atoi(args[0])
 | 
				
			||||||
        except ValueError, msg:
 | 
					        except ValueError as msg:
 | 
				
			||||||
            usage(msg)
 | 
					            usage(msg)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        port = PORT
 | 
					        port = PORT
 | 
				
			||||||
| 
						 | 
					@ -83,7 +83,7 @@ def run_interpreter(stdin, stdout):
 | 
				
			||||||
        source = source + line
 | 
					        source = source + line
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            code = compile_command(source)
 | 
					            code = compile_command(source)
 | 
				
			||||||
        except SyntaxError, err:
 | 
					        except SyntaxError as err:
 | 
				
			||||||
            source = ""
 | 
					            source = ""
 | 
				
			||||||
            traceback.print_exception(SyntaxError, err, None, file=stdout)
 | 
					            traceback.print_exception(SyntaxError, err, None, file=stdout)
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
| 
						 | 
					@ -92,7 +92,7 @@ def run_interpreter(stdin, stdout):
 | 
				
			||||||
        source = ""
 | 
					        source = ""
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            run_command(code, stdin, stdout, globals)
 | 
					            run_command(code, stdin, stdout, globals)
 | 
				
			||||||
        except SystemExit, how:
 | 
					        except SystemExit as how:
 | 
				
			||||||
            if how:
 | 
					            if how:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    how = str(how)
 | 
					                    how = str(how)
 | 
				
			||||||
| 
						 | 
					@ -109,7 +109,7 @@ def run_command(code, stdin, stdout, globals):
 | 
				
			||||||
        sys.stdin = stdin
 | 
					        sys.stdin = stdin
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            exec(code, globals)
 | 
					            exec(code, globals)
 | 
				
			||||||
        except SystemExit, how:
 | 
					        except SystemExit as how:
 | 
				
			||||||
            raise SystemExit, how, sys.exc_info()[2]
 | 
					            raise SystemExit, how, sys.exc_info()[2]
 | 
				
			||||||
        except:
 | 
					        except:
 | 
				
			||||||
            type, value, tb = sys.exc_info()
 | 
					            type, value, tb = sys.exc_info()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -194,8 +194,7 @@ def test():
 | 
				
			||||||
    fh = sf[1]
 | 
					    fh = sf[1]
 | 
				
			||||||
    if fh:
 | 
					    if fh:
 | 
				
			||||||
        ncl = NFSClient(host)
 | 
					        ncl = NFSClient(host)
 | 
				
			||||||
        as = ncl.Getattr(fh)
 | 
					        print ncl.Getattr(fh)
 | 
				
			||||||
        print as
 | 
					 | 
				
			||||||
        list = ncl.Listdir(fh)
 | 
					        list = ncl.Listdir(fh)
 | 
				
			||||||
        for item in list: print item
 | 
					        for item in list: print item
 | 
				
			||||||
        mcl.Umnt(filesys)
 | 
					        mcl.Umnt(filesys)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -330,7 +330,8 @@ def bindresvport(sock, host):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            sock.bind((host, i))
 | 
					            sock.bind((host, i))
 | 
				
			||||||
            return last_resv_port_tried
 | 
					            return last_resv_port_tried
 | 
				
			||||||
        except socket.error, (errno, msg):
 | 
					        except socket.error as e:
 | 
				
			||||||
 | 
					            (errno, msg) = e
 | 
				
			||||||
            if errno != 114:
 | 
					            if errno != 114:
 | 
				
			||||||
                raise socket.error, (errno, msg)
 | 
					                raise socket.error, (errno, msg)
 | 
				
			||||||
    raise RuntimeError, 'can\'t assign reserved port'
 | 
					    raise RuntimeError, 'can\'t assign reserved port'
 | 
				
			||||||
| 
						 | 
					@ -765,7 +766,7 @@ def session(self, connection):
 | 
				
			||||||
                call = recvrecord(sock)
 | 
					                call = recvrecord(sock)
 | 
				
			||||||
            except EOFError:
 | 
					            except EOFError:
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
            except socket.error, msg:
 | 
					            except socket.error as msg:
 | 
				
			||||||
                print 'socket error:', msg
 | 
					                print 'socket error:', msg
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
            reply = self.handle(call)
 | 
					            reply = self.handle(call)
 | 
				
			||||||
| 
						 | 
					@ -866,7 +867,7 @@ def handle_1(self):
 | 
				
			||||||
    s = S('', 0x20000000, 1, 0)
 | 
					    s = S('', 0x20000000, 1, 0)
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        s.unregister()
 | 
					        s.unregister()
 | 
				
			||||||
    except RuntimeError, msg:
 | 
					    except RuntimeError as msg:
 | 
				
			||||||
        print 'RuntimeError:', msg, '(ignored)'
 | 
					        print 'RuntimeError:', msg, '(ignored)'
 | 
				
			||||||
    s.register()
 | 
					    s.register()
 | 
				
			||||||
    print 'Service started...'
 | 
					    print 'Service started...'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,7 @@ def recursedown(dirname):
 | 
				
			||||||
    bad = 0
 | 
					    bad = 0
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        names = os.listdir(dirname)
 | 
					        names = os.listdir(dirname)
 | 
				
			||||||
    except os.error, msg:
 | 
					    except os.error as msg:
 | 
				
			||||||
        err('%s: cannot list directory: %r\n' % (dirname, msg))
 | 
					        err('%s: cannot list directory: %r\n' % (dirname, msg))
 | 
				
			||||||
        return 1
 | 
					        return 1
 | 
				
			||||||
    names.sort()
 | 
					    names.sort()
 | 
				
			||||||
| 
						 | 
					@ -83,7 +83,7 @@ def fix(filename):
 | 
				
			||||||
##      dbg('fix(%r)\n' % (dirname,))
 | 
					##      dbg('fix(%r)\n' % (dirname,))
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        f = open(filename, 'r')
 | 
					        f = open(filename, 'r')
 | 
				
			||||||
    except IOError, msg:
 | 
					    except IOError as msg:
 | 
				
			||||||
        err('%s: cannot open: %r\n' % (filename, msg))
 | 
					        err('%s: cannot open: %r\n' % (filename, msg))
 | 
				
			||||||
        return 1
 | 
					        return 1
 | 
				
			||||||
    head, tail = os.path.split(filename)
 | 
					    head, tail = os.path.split(filename)
 | 
				
			||||||
| 
						 | 
					@ -120,7 +120,7 @@ def fix(filename):
 | 
				
			||||||
            if g is None:
 | 
					            if g is None:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    g = open(tempname, 'w')
 | 
					                    g = open(tempname, 'w')
 | 
				
			||||||
                except IOError, msg:
 | 
					                except IOError as msg:
 | 
				
			||||||
                    f.close()
 | 
					                    f.close()
 | 
				
			||||||
                    err('%s: cannot create: %r\n' % (tempname, msg))
 | 
					                    err('%s: cannot create: %r\n' % (tempname, msg))
 | 
				
			||||||
                    return 1
 | 
					                    return 1
 | 
				
			||||||
| 
						 | 
					@ -144,17 +144,17 @@ def fix(filename):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        statbuf = os.stat(filename)
 | 
					        statbuf = os.stat(filename)
 | 
				
			||||||
        os.chmod(tempname, statbuf[ST_MODE] & 07777)
 | 
					        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))
 | 
					        err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
 | 
				
			||||||
    # Then make a backup of the original file as filename~
 | 
					    # Then make a backup of the original file as filename~
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        os.rename(filename, filename + '~')
 | 
					        os.rename(filename, filename + '~')
 | 
				
			||||||
    except os.error, msg:
 | 
					    except os.error as msg:
 | 
				
			||||||
        err('%s: warning: backup failed (%r)\n' % (filename, msg))
 | 
					        err('%s: warning: backup failed (%r)\n' % (filename, msg))
 | 
				
			||||||
    # Now move the temp file to the original file
 | 
					    # Now move the temp file to the original file
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        os.rename(tempname, filename)
 | 
					        os.rename(tempname, filename)
 | 
				
			||||||
    except os.error, msg:
 | 
					    except os.error as msg:
 | 
				
			||||||
        err('%s: rename failed (%r)\n' % (filename, msg))
 | 
					        err('%s: rename failed (%r)\n' % (filename, msg))
 | 
				
			||||||
        return 1
 | 
					        return 1
 | 
				
			||||||
    # Return succes
 | 
					    # Return succes
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ def main():
 | 
				
			||||||
    search = None
 | 
					    search = None
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        opts, args = getopt.getopt(sys.argv[1:], 'm:s:')
 | 
					        opts, args = getopt.getopt(sys.argv[1:], 'm:s:')
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
        print 'usage: ftpstats [-m maxitems] [file]'
 | 
					        print 'usage: ftpstats [-m maxitems] [file]'
 | 
				
			||||||
        sys.exit(2)
 | 
					        sys.exit(2)
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ def main():
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            f = open(file, 'r')
 | 
					            f = open(file, 'r')
 | 
				
			||||||
        except IOError, msg:
 | 
					        except IOError as msg:
 | 
				
			||||||
            print file, ':', msg
 | 
					            print file, ':', msg
 | 
				
			||||||
            sys.exit(1)
 | 
					            sys.exit(1)
 | 
				
			||||||
    bydate = {}
 | 
					    bydate = {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,7 @@ def main():
 | 
				
			||||||
    dofile = mmdf
 | 
					    dofile = mmdf
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        opts, args = getopt.getopt(sys.argv[1:], 'f')
 | 
					        opts, args = getopt.getopt(sys.argv[1:], 'f')
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        sys.stderr.write('%s\n' % msg)
 | 
					        sys.stderr.write('%s\n' % msg)
 | 
				
			||||||
        sys.exit(2)
 | 
					        sys.exit(2)
 | 
				
			||||||
    for o, a in opts:
 | 
					    for o, a in opts:
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@ def main():
 | 
				
			||||||
        elif os.path.isfile(arg):
 | 
					        elif os.path.isfile(arg):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                f = open(arg)
 | 
					                f = open(arg)
 | 
				
			||||||
            except IOError, msg:
 | 
					            except IOError as msg:
 | 
				
			||||||
                sys.stderr.write('%s: %s\n' % (arg, msg))
 | 
					                sys.stderr.write('%s: %s\n' % (arg, msg))
 | 
				
			||||||
                sts = 1
 | 
					                sts = 1
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ def mh(dir):
 | 
				
			||||||
        fn = os.path.join(dir, msg)
 | 
					        fn = os.path.join(dir, msg)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            f = open(fn)
 | 
					            f = open(fn)
 | 
				
			||||||
        except IOError, msg:
 | 
					        except IOError as msg:
 | 
				
			||||||
            sys.stderr.write('%s: %s\n' % (fn, msg))
 | 
					            sys.stderr.write('%s: %s\n' % (fn, msg))
 | 
				
			||||||
            sts = 1
 | 
					            sts = 1
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -330,7 +330,7 @@ def main():
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            s = NNTP(newshost)
 | 
					            s = NNTP(newshost)
 | 
				
			||||||
        connected = 1
 | 
					        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 'Error connecting to host:', x
 | 
				
			||||||
        print 'I\'ll try to use just the local list.'
 | 
					        print 'I\'ll try to use just the local list.'
 | 
				
			||||||
        connected = 0
 | 
					        connected = 0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    optlist, ARGS = getopt.getopt(sys.argv[1:], 'acde:F:np')
 | 
					    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.stderr.write(sys.argv[0] + ': ' + msg + '\n')
 | 
				
			||||||
    sys.exit(2)
 | 
					    sys.exit(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ def __init__(self, filename):
 | 
				
			||||||
        self.changed = 0
 | 
					        self.changed = 0
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.lines = open(filename, 'r').readlines()
 | 
					            self.lines = open(filename, 'r').readlines()
 | 
				
			||||||
        except IOError, msg:
 | 
					        except IOError as msg:
 | 
				
			||||||
            print '*** Can\'t open "%s":' % filename, msg
 | 
					            print '*** Can\'t open "%s":' % filename, msg
 | 
				
			||||||
            self.lines = None
 | 
					            self.lines = None
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ def finish(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            os.rename(self.filename, self.filename + '~')
 | 
					            os.rename(self.filename, self.filename + '~')
 | 
				
			||||||
            fp = open(self.filename, 'w')
 | 
					            fp = open(self.filename, 'w')
 | 
				
			||||||
        except (os.error, IOError), msg:
 | 
					        except (os.error, IOError) as msg:
 | 
				
			||||||
            print '*** Can\'t rewrite "%s":' % self.filename, msg
 | 
					            print '*** Can\'t rewrite "%s":' % self.filename, msg
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        print 'writing', self.filename
 | 
					        print 'writing', self.filename
 | 
				
			||||||
| 
						 | 
					@ -67,7 +67,7 @@ def main():
 | 
				
			||||||
    if sys.argv[1:]:
 | 
					    if sys.argv[1:]:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            fp = open(sys.argv[1], 'r')
 | 
					            fp = open(sys.argv[1], 'r')
 | 
				
			||||||
        except IOError, msg:
 | 
					        except IOError as msg:
 | 
				
			||||||
            print 'Can\'t open "%s":' % sys.argv[1], msg
 | 
					            print 'Can\'t open "%s":' % sys.argv[1], msg
 | 
				
			||||||
            sys.exit(1)
 | 
					            sys.exit(1)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,7 +142,7 @@ def browser(*args):
 | 
				
			||||||
        raise RuntimeError, 'too many args'
 | 
					        raise RuntimeError, 'too many args'
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        browse_menu(selector, host, port)
 | 
					        browse_menu(selector, host, port)
 | 
				
			||||||
    except socket.error, msg:
 | 
					    except socket.error as msg:
 | 
				
			||||||
        print 'Socket error:', msg
 | 
					        print 'Socket error:', msg
 | 
				
			||||||
        sys.exit(1)
 | 
					        sys.exit(1)
 | 
				
			||||||
    except KeyboardInterrupt:
 | 
					    except KeyboardInterrupt:
 | 
				
			||||||
| 
						 | 
					@ -202,7 +202,7 @@ def browse_textfile(selector, host, port):
 | 
				
			||||||
        p = os.popen('${PAGER-more}', 'w')
 | 
					        p = os.popen('${PAGER-more}', 'w')
 | 
				
			||||||
        x = SaveLines(p)
 | 
					        x = SaveLines(p)
 | 
				
			||||||
        get_alt_textfile(selector, host, port, x.writeln)
 | 
					        get_alt_textfile(selector, host, port, x.writeln)
 | 
				
			||||||
    except IOError, msg:
 | 
					    except IOError as msg:
 | 
				
			||||||
        print 'IOError:', msg
 | 
					        print 'IOError:', msg
 | 
				
			||||||
    if x:
 | 
					    if x:
 | 
				
			||||||
        x.close()
 | 
					        x.close()
 | 
				
			||||||
| 
						 | 
					@ -213,7 +213,7 @@ def browse_textfile(selector, host, port):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        get_alt_textfile(selector, host, port, x.writeln)
 | 
					        get_alt_textfile(selector, host, port, x.writeln)
 | 
				
			||||||
        print 'Done.'
 | 
					        print 'Done.'
 | 
				
			||||||
    except IOError, msg:
 | 
					    except IOError as msg:
 | 
				
			||||||
        print 'IOError:', msg
 | 
					        print 'IOError:', msg
 | 
				
			||||||
    x.close()
 | 
					    x.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -311,7 +311,7 @@ def open_savefile():
 | 
				
			||||||
        cmd = savefile[1:].strip()
 | 
					        cmd = savefile[1:].strip()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            p = os.popen(cmd, 'w')
 | 
					            p = os.popen(cmd, 'w')
 | 
				
			||||||
        except IOError, msg:
 | 
					        except IOError as msg:
 | 
				
			||||||
            print repr(cmd), ':', msg
 | 
					            print repr(cmd), ':', msg
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
        print 'Piping through', repr(cmd), '...'
 | 
					        print 'Piping through', repr(cmd), '...'
 | 
				
			||||||
| 
						 | 
					@ -320,7 +320,7 @@ def open_savefile():
 | 
				
			||||||
        savefile = os.path.expanduser(savefile)
 | 
					        savefile = os.path.expanduser(savefile)
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        f = open(savefile, 'w')
 | 
					        f = open(savefile, 'w')
 | 
				
			||||||
    except IOError, msg:
 | 
					    except IOError as msg:
 | 
				
			||||||
        print repr(savefile), ':', msg
 | 
					        print repr(savefile), ':', msg
 | 
				
			||||||
        return None
 | 
					        return None
 | 
				
			||||||
    print 'Saving to', repr(savefile), '...'
 | 
					    print 'Saving to', repr(savefile), '...'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,7 +52,7 @@ def main():
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        s.connect((host, port))
 | 
					        s.connect((host, port))
 | 
				
			||||||
    except error, msg:
 | 
					    except error as msg:
 | 
				
			||||||
        sys.stderr.write('connect failed: ' + repr(msg) + '\n')
 | 
					        sys.stderr.write('connect failed: ' + repr(msg) + '\n')
 | 
				
			||||||
        sys.exit(1)
 | 
					        sys.exit(1)
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,7 +131,7 @@ def selector(dir, name, fullname, stat):
 | 
				
			||||||
def find(dir, pred, wq):
 | 
					def find(dir, pred, wq):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        names = os.listdir(dir)
 | 
					        names = os.listdir(dir)
 | 
				
			||||||
    except os.error, msg:
 | 
					    except os.error as msg:
 | 
				
			||||||
        print repr(dir), ':', msg
 | 
					        print repr(dir), ':', msg
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
    for name in names:
 | 
					    for name in names:
 | 
				
			||||||
| 
						 | 
					@ -139,7 +139,7 @@ def find(dir, pred, wq):
 | 
				
			||||||
            fullname = os.path.join(dir, name)
 | 
					            fullname = os.path.join(dir, name)
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                stat = os.lstat(fullname)
 | 
					                stat = os.lstat(fullname)
 | 
				
			||||||
            except os.error, msg:
 | 
					            except os.error as msg:
 | 
				
			||||||
                print repr(fullname), ':', msg
 | 
					                print repr(fullname), ':', msg
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            if pred(dir, name, fullname, stat):
 | 
					            if pred(dir, name, fullname, stat):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ def main():
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        s.connect((host, port))
 | 
					        s.connect((host, port))
 | 
				
			||||||
    except error, msg:
 | 
					    except error as msg:
 | 
				
			||||||
        sys.stderr.write('connect failed: %r\n' % (msg,))
 | 
					        sys.stderr.write('connect failed: %r\n' % (msg,))
 | 
				
			||||||
        sys.exit(1)
 | 
					        sys.exit(1)
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -156,7 +156,7 @@ def set(self, e=None):
 | 
				
			||||||
            self.current = self.var.get()
 | 
					            self.current = self.var.get()
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.dialog.widget.pack(**{self.option: self.current})
 | 
					                self.dialog.widget.pack(**{self.option: self.current})
 | 
				
			||||||
            except TclError, msg:
 | 
					            except TclError as msg:
 | 
				
			||||||
                print msg
 | 
					                print msg
 | 
				
			||||||
                self.refresh()
 | 
					                self.refresh()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -212,7 +212,7 @@ def refresh(self):
 | 
				
			||||||
                                     'pack',
 | 
					                                     'pack',
 | 
				
			||||||
                                     'info',
 | 
					                                     'info',
 | 
				
			||||||
                                     self.widget))
 | 
					                                     self.widget))
 | 
				
			||||||
        except TclError, msg:
 | 
					        except TclError as msg:
 | 
				
			||||||
            print msg
 | 
					            print msg
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        dict = {}
 | 
					        dict = {}
 | 
				
			||||||
| 
						 | 
					@ -239,7 +239,7 @@ def set(self, e=None):
 | 
				
			||||||
                        '-'+self.option,
 | 
					                        '-'+self.option,
 | 
				
			||||||
                        self.dialog.master.tk.merge(
 | 
					                        self.dialog.master.tk.merge(
 | 
				
			||||||
                                self.current))
 | 
					                                self.current))
 | 
				
			||||||
            except TclError, msg:
 | 
					            except TclError as msg:
 | 
				
			||||||
                print msg
 | 
					                print msg
 | 
				
			||||||
                self.refresh()
 | 
					                self.refresh()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -285,7 +285,7 @@ def set(self, e=None):
 | 
				
			||||||
            self.current = self.var.get()
 | 
					            self.current = self.var.get()
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.dialog.widget[self.option] = self.current
 | 
					                self.dialog.widget[self.option] = self.current
 | 
				
			||||||
            except TclError, msg:
 | 
					            except TclError as msg:
 | 
				
			||||||
                print msg
 | 
					                print msg
 | 
				
			||||||
                self.refresh()
 | 
					                self.refresh()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -374,7 +374,7 @@ def refresh(self):
 | 
				
			||||||
                    self.master.send(self.app,
 | 
					                    self.master.send(self.app,
 | 
				
			||||||
                                     self.widget,
 | 
					                                     self.widget,
 | 
				
			||||||
                                     'config'))
 | 
					                                     'config'))
 | 
				
			||||||
        except TclError, msg:
 | 
					        except TclError as msg:
 | 
				
			||||||
            print msg
 | 
					            print msg
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        dict = {}
 | 
					        dict = {}
 | 
				
			||||||
| 
						 | 
					@ -398,7 +398,7 @@ def set(self, e=None):
 | 
				
			||||||
                        'config',
 | 
					                        'config',
 | 
				
			||||||
                        '-'+self.option,
 | 
					                        '-'+self.option,
 | 
				
			||||||
                        self.current)
 | 
					                        self.current)
 | 
				
			||||||
            except TclError, msg:
 | 
					            except TclError as msg:
 | 
				
			||||||
                print msg
 | 
					                print msg
 | 
				
			||||||
                self.refresh()
 | 
					                self.refresh()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -445,7 +445,7 @@ def opendialogs(e):
 | 
				
			||||||
        if widget == '.': continue
 | 
					        if widget == '.': continue
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            RemotePackDialog(list, list.app, widget)
 | 
					            RemotePackDialog(list, list.app, widget)
 | 
				
			||||||
        except TclError, msg:
 | 
					        except TclError as msg:
 | 
				
			||||||
            print msg
 | 
					            print msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test()
 | 
					test()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,7 +95,7 @@ def _endparser(self):
 | 
				
			||||||
            self._parseline('')
 | 
					            self._parseline('')
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.tk.deletefilehandler(self.fp)
 | 
					            self.tk.deletefilehandler(self.fp)
 | 
				
			||||||
        except TclError, msg:
 | 
					        except TclError as msg:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
        self.fp.close()
 | 
					        self.fp.close()
 | 
				
			||||||
        self.fp = None
 | 
					        self.fp = None
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@ def main():
 | 
				
			||||||
    seq = 'all'
 | 
					    seq = 'all'
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        opts, args = getopt.getopt(sys.argv[1:], '')
 | 
					        opts, args = getopt.getopt(sys.argv[1:], '')
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
        sys.exit(2)
 | 
					        sys.exit(2)
 | 
				
			||||||
    for arg in args:
 | 
					    for arg in args:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -216,7 +216,7 @@ def search_string(self, search):
 | 
				
			||||||
                prog = re.compile(search, map)
 | 
					                prog = re.compile(search, map)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                prog = re.compile(search)
 | 
					                prog = re.compile(search)
 | 
				
			||||||
        except re.error, msg:
 | 
					        except re.error as msg:
 | 
				
			||||||
            self.frame.bell()
 | 
					            self.frame.bell()
 | 
				
			||||||
            print 'Regex error:', msg
 | 
					            print 'Regex error:', msg
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@
 | 
				
			||||||
        tk.record(line)
 | 
					        tk.record(line)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            result = tk.call('eval', cmd)
 | 
					            result = tk.call('eval', cmd)
 | 
				
			||||||
        except _tkinter.TclError, msg:
 | 
					        except _tkinter.TclError as msg:
 | 
				
			||||||
            print 'TclError:', msg
 | 
					            print 'TclError:', msg
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            if result: print result
 | 
					            if result: print result
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -214,7 +214,7 @@ e.g. ::
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> req = urllib2.Request('http://www.pretend_server.org')
 | 
					    >>> req = urllib2.Request('http://www.pretend_server.org')
 | 
				
			||||||
    >>> try: urllib2.urlopen(req)
 | 
					    >>> try: urllib2.urlopen(req)
 | 
				
			||||||
    >>> except URLError, e:
 | 
					    >>> except URLError as e:
 | 
				
			||||||
    >>>    print e.reason
 | 
					    >>>    print e.reason
 | 
				
			||||||
    >>>
 | 
					    >>>
 | 
				
			||||||
    (4, 'getaddrinfo failed')
 | 
					    (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')
 | 
					    >>> req = urllib2.Request('http://www.python.org/fish.html')
 | 
				
			||||||
    >>> try: 
 | 
					    >>> try: 
 | 
				
			||||||
    >>>     urllib2.urlopen(req)
 | 
					    >>>     urllib2.urlopen(req)
 | 
				
			||||||
    >>> except URLError, e:
 | 
					    >>> except URLError as e:
 | 
				
			||||||
    >>>     print e.code
 | 
					    >>>     print e.code
 | 
				
			||||||
    >>>     print e.read()
 | 
					    >>>     print e.read()
 | 
				
			||||||
    >>> 
 | 
					    >>> 
 | 
				
			||||||
| 
						 | 
					@ -354,10 +354,10 @@ Number 1
 | 
				
			||||||
    req = Request(someurl)
 | 
					    req = Request(someurl)
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        response = urlopen(req)
 | 
					        response = urlopen(req)
 | 
				
			||||||
    except HTTPError, e:
 | 
					    except HTTPError as e:
 | 
				
			||||||
        print 'The server couldn\'t fulfill the request.'
 | 
					        print 'The server couldn\'t fulfill the request.'
 | 
				
			||||||
        print 'Error code: ', e.code
 | 
					        print 'Error code: ', e.code
 | 
				
			||||||
    except URLError, e:
 | 
					    except URLError as e:
 | 
				
			||||||
        print 'We failed to reach a server.'
 | 
					        print 'We failed to reach a server.'
 | 
				
			||||||
        print 'Reason: ', e.reason
 | 
					        print 'Reason: ', e.reason
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
| 
						 | 
					@ -378,7 +378,7 @@ Number 2
 | 
				
			||||||
    req = Request(someurl)
 | 
					    req = Request(someurl)
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        response = urlopen(req)
 | 
					        response = urlopen(req)
 | 
				
			||||||
    except URLError, e:
 | 
					    except URLError as e:
 | 
				
			||||||
        if hasattr(e, 'reason'):
 | 
					        if hasattr(e, 'reason'):
 | 
				
			||||||
            print 'We failed to reach a server.'
 | 
					            print 'We failed to reach a server.'
 | 
				
			||||||
            print 'Reason: ', e.reason
 | 
					            print 'Reason: ', e.reason
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ def main():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        os.mkdir(opts.directory)
 | 
					        os.mkdir(opts.directory)
 | 
				
			||||||
    except OSError, e:
 | 
					    except OSError as e:
 | 
				
			||||||
        # Ignore directory exists error
 | 
					        # Ignore directory exists error
 | 
				
			||||||
        if e.errno != errno.EEXIST:
 | 
					        if e.errno != errno.EEXIST:
 | 
				
			||||||
            raise
 | 
					            raise
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -426,7 +426,7 @@ reader = csv.reader(open(filename, "rb"))
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    for row in reader:
 | 
					    for row in reader:
 | 
				
			||||||
        print row
 | 
					        print row
 | 
				
			||||||
except csv.Error, e:
 | 
					except csv.Error as e:
 | 
				
			||||||
    sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e))
 | 
					    sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e))
 | 
				
			||||||
\end{verbatim}
 | 
					\end{verbatim}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,7 +126,7 @@ import getopt, sys
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
 | 
					        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 help information and exit:
 | 
				
			||||||
        print str(err) # will print something like "option -a not recognized"
 | 
					        print str(err) # will print something like "option -a not recognized"
 | 
				
			||||||
        usage()
 | 
					        usage()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,6 +144,6 @@ def copytree(src, dst, symlinks=0):
 | 
				
			||||||
                copytree(srcname, dstname, symlinks)
 | 
					                copytree(srcname, dstname, symlinks)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                copy2(srcname, dstname)
 | 
					                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))
 | 
					            print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))
 | 
				
			||||||
\end{verbatim}
 | 
					\end{verbatim}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -813,13 +813,13 @@ for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM,
 | 
				
			||||||
    af, socktype, proto, canonname, sa = res
 | 
					    af, socktype, proto, canonname, sa = res
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
	s = socket.socket(af, socktype, proto)
 | 
						s = socket.socket(af, socktype, proto)
 | 
				
			||||||
    except socket.error, msg:
 | 
					    except socket.error as msg:
 | 
				
			||||||
	s = None
 | 
						s = None
 | 
				
			||||||
	continue
 | 
						continue
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
	s.bind(sa)
 | 
						s.bind(sa)
 | 
				
			||||||
	s.listen(1)
 | 
						s.listen(1)
 | 
				
			||||||
    except socket.error, msg:
 | 
					    except socket.error as msg:
 | 
				
			||||||
	s.close()
 | 
						s.close()
 | 
				
			||||||
	s = None
 | 
						s = None
 | 
				
			||||||
	continue
 | 
						continue
 | 
				
			||||||
| 
						 | 
					@ -848,12 +848,12 @@ for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM):
 | 
				
			||||||
    af, socktype, proto, canonname, sa = res
 | 
					    af, socktype, proto, canonname, sa = res
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
	s = socket.socket(af, socktype, proto)
 | 
						s = socket.socket(af, socktype, proto)
 | 
				
			||||||
    except socket.error, msg:
 | 
					    except socket.error as msg:
 | 
				
			||||||
	s = None
 | 
						s = None
 | 
				
			||||||
	continue
 | 
						continue
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
	s.connect(sa)
 | 
						s.connect(sa)
 | 
				
			||||||
    except socket.error, msg:
 | 
					    except socket.error as msg:
 | 
				
			||||||
	s.close()
 | 
						s.close()
 | 
				
			||||||
	s = None
 | 
						s = None
 | 
				
			||||||
	continue
 | 
						continue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -284,7 +284,7 @@ try:
 | 
				
			||||||
        print >>sys.stderr, "Child was terminated by signal", -retcode
 | 
					        print >>sys.stderr, "Child was terminated by signal", -retcode
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print >>sys.stderr, "Child returned", retcode
 | 
					        print >>sys.stderr, "Child returned", retcode
 | 
				
			||||||
except OSError, e:
 | 
					except OSError as e:
 | 
				
			||||||
    print >>sys.stderr, "Execution failed:", e
 | 
					    print >>sys.stderr, "Execution failed:", e
 | 
				
			||||||
\end{verbatim}
 | 
					\end{verbatim}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -246,6 +246,6 @@ import xdrlib
 | 
				
			||||||
p = xdrlib.Packer()
 | 
					p = xdrlib.Packer()
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    p.pack_double(8.01)
 | 
					    p.pack_double(8.01)
 | 
				
			||||||
except xdrlib.ConversionError, instance:
 | 
					except xdrlib.ConversionError as instance:
 | 
				
			||||||
    print 'packing the double failed:', instance.msg
 | 
					    print 'packing the double failed:', instance.msg
 | 
				
			||||||
\end{verbatim}
 | 
					\end{verbatim}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -358,7 +358,7 @@ print server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    print server.examples.getStateName(41)
 | 
					    print server.examples.getStateName(41)
 | 
				
			||||||
except Error, v:
 | 
					except Error as v:
 | 
				
			||||||
    print "ERROR", v
 | 
					    print "ERROR", v
 | 
				
			||||||
\end{verbatim}
 | 
					\end{verbatim}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if buffer.lstrip().upper().startswith("SELECT"):
 | 
					            if buffer.lstrip().upper().startswith("SELECT"):
 | 
				
			||||||
                print cur.fetchall()
 | 
					                print cur.fetchall()
 | 
				
			||||||
        except sqlite3.Error, e:
 | 
					        except sqlite3.Error as e:
 | 
				
			||||||
            print "An error occurred:", e.args[0]
 | 
					            print "An error occurred:", e.args[0]
 | 
				
			||||||
        buffer = ""
 | 
					        buffer = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -127,7 +127,7 @@ def main():
 | 
				
			||||||
                print_list(undocumented, "Undocumented symbols")
 | 
					                print_list(undocumented, "Undocumented symbols")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print_list(L)
 | 
					            print_list(L)
 | 
				
			||||||
    except IOError, e:
 | 
					    except IOError as e:
 | 
				
			||||||
        if e.errno != errno.EPIPE:
 | 
					        if e.errno != errno.EPIPE:
 | 
				
			||||||
            raise
 | 
					            raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,7 +53,7 @@ def main():
 | 
				
			||||||
        opts, args = getopt.getopt(
 | 
					        opts, args = getopt.getopt(
 | 
				
			||||||
            args, "abchi:",
 | 
					            args, "abchi:",
 | 
				
			||||||
            ["annotate", "built-in", "categorize", "help", "ignore-from="])
 | 
					            ["annotate", "built-in", "categorize", "help", "ignore-from="])
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        sys.stdout = sys.stderr
 | 
					        sys.stdout = sys.stderr
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -599,7 +599,7 @@ def main():
 | 
				
			||||||
    options = Options()
 | 
					    options = Options()
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        args = options.parse(sys.argv[1:])
 | 
					        args = options.parse(sys.argv[1:])
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        error(options, msg)
 | 
					        error(options, msg)
 | 
				
			||||||
    if not args:
 | 
					    if not args:
 | 
				
			||||||
        # attempt to locate single .tex file in current directory:
 | 
					        # attempt to locate single .tex file in current directory:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ def main():
 | 
				
			||||||
          opts, args = getopt.getopt(sys.argv[1:], "Aabgtzq",
 | 
					          opts, args = getopt.getopt(sys.argv[1:], "Aabgtzq",
 | 
				
			||||||
                                     ["all", "bzip2", "gzip", "tools", "zip",
 | 
					                                     ["all", "bzip2", "gzip", "tools", "zip",
 | 
				
			||||||
                                      "quiet", "anonymous"])
 | 
					                                      "quiet", "anonymous"])
 | 
				
			||||||
     except getopt.error, e:
 | 
					     except getopt.error as e:
 | 
				
			||||||
          usage(warning=str(e))
 | 
					          usage(warning=str(e))
 | 
				
			||||||
          sys.exit(2)
 | 
					          sys.exit(2)
 | 
				
			||||||
     if len(args) not in (1, 2):
 | 
					     if len(args) not in (1, 2):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -448,7 +448,7 @@ def do_project(library, output, arch, version):
 | 
				
			||||||
def openfile(file):
 | 
					def openfile(file):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        p = open(file, "w")
 | 
					        p = open(file, "w")
 | 
				
			||||||
    except IOError, msg:
 | 
					    except IOError as msg:
 | 
				
			||||||
        print file, ":", msg
 | 
					        print file, ":", msg
 | 
				
			||||||
        sys.exit(1)
 | 
					        sys.exit(1)
 | 
				
			||||||
    return p
 | 
					    return p
 | 
				
			||||||
| 
						 | 
					@ -466,7 +466,7 @@ def do_it(args = None):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        optlist, args = getopt.getopt(args, 'ckpv:')
 | 
					        optlist, args = getopt.getopt(args, 'ckpv:')
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
        usage()
 | 
					        usage()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1039,7 +1039,8 @@ def convert(ifp, ofp):
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        write_esis(fragment, ofp, knownempty)
 | 
					        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
 | 
					        # Ignore EPIPE; it just means that whoever we're writing to stopped
 | 
				
			||||||
        # reading.  The rest of the output would be ignored.  All other errors
 | 
					        # reading.  The rest of the output would be ignored.  All other errors
 | 
				
			||||||
        # should still be reported,
 | 
					        # should still be reported,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -255,7 +255,8 @@ def main():
 | 
				
			||||||
        if xml and xmldecl:
 | 
					        if xml and xmldecl:
 | 
				
			||||||
            opf.write('<?xml version="1.0" encoding="iso8859-1"?>\n')
 | 
					            opf.write('<?xml version="1.0" encoding="iso8859-1"?>\n')
 | 
				
			||||||
        convert(ifp, ofp, xml=xml, autoclose=autoclose, verbatims=verbatims)
 | 
					        convert(ifp, ofp, xml=xml, autoclose=autoclose, verbatims=verbatims)
 | 
				
			||||||
    except IOError, (err, msg):
 | 
					    except IOError as e:
 | 
				
			||||||
 | 
					        (err, msg) = e
 | 
				
			||||||
        if err != errno.EPIPE:
 | 
					        if err != errno.EPIPE:
 | 
				
			||||||
            raise
 | 
					            raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -139,7 +139,7 @@ def close(self):
 | 
				
			||||||
    def _get_token(self, fp):
 | 
					    def _get_token(self, fp):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            line = fp.readline()
 | 
					            line = fp.readline()
 | 
				
			||||||
        except IOError, e:
 | 
					        except IOError as e:
 | 
				
			||||||
            e = SAXException("I/O error reading input stream", e)
 | 
					            e = SAXException("I/O error reading input stream", e)
 | 
				
			||||||
            self.getErrorHandler().fatalError(e)
 | 
					            self.getErrorHandler().fatalError(e)
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -397,7 +397,8 @@ def convert(ifp, ofp, table):
 | 
				
			||||||
    c = Conversion(ifp, ofp, table)
 | 
					    c = Conversion(ifp, ofp, table)
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        c.convert()
 | 
					        c.convert()
 | 
				
			||||||
    except IOError, (err, msg):
 | 
					    except IOError as e:
 | 
				
			||||||
 | 
					        (err, msg) = e
 | 
				
			||||||
        if err != errno.EPIPE:
 | 
					        if err != errno.EPIPE:
 | 
				
			||||||
            raise
 | 
					            raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3480,8 +3480,9 @@ try:
 | 
				
			||||||
    f = open('myfile.txt')
 | 
					    f = open('myfile.txt')
 | 
				
			||||||
    s = f.readline()
 | 
					    s = f.readline()
 | 
				
			||||||
    i = int(s.strip())
 | 
					    i = int(s.strip())
 | 
				
			||||||
except IOError, (errno, strerror):
 | 
					except IOError as e:
 | 
				
			||||||
    print "I/O error(%s): %s" % (errno, strerror)
 | 
					    (errno, strerror) = e
 | 
				
			||||||
 | 
					    print "I/O error(%s): %s" % (e.errno, e.strerror)
 | 
				
			||||||
except ValueError:
 | 
					except ValueError:
 | 
				
			||||||
    print "Could not convert data to an integer."
 | 
					    print "Could not convert data to an integer."
 | 
				
			||||||
except:
 | 
					except:
 | 
				
			||||||
| 
						 | 
					@ -3530,7 +3531,7 @@ as desired.
 | 
				
			||||||
\begin{verbatim}
 | 
					\begin{verbatim}
 | 
				
			||||||
>>> try:
 | 
					>>> try:
 | 
				
			||||||
...    raise Exception('spam', 'eggs')
 | 
					...    raise Exception('spam', 'eggs')
 | 
				
			||||||
... except Exception, inst:
 | 
					... except Exception as inst:
 | 
				
			||||||
...    print type(inst)     # the exception instance
 | 
					...    print type(inst)     # the exception instance
 | 
				
			||||||
...    print inst.args      # arguments stored in .args
 | 
					...    print inst.args      # arguments stored in .args
 | 
				
			||||||
...    print inst           # __str__ allows args to printed directly
 | 
					...    print inst           # __str__ allows args to printed directly
 | 
				
			||||||
| 
						 | 
					@ -3559,7 +3560,7 @@ For example:
 | 
				
			||||||
... 
 | 
					... 
 | 
				
			||||||
>>> try:
 | 
					>>> try:
 | 
				
			||||||
...     this_fails()
 | 
					...     this_fails()
 | 
				
			||||||
... except ZeroDivisionError, detail:
 | 
					... except ZeroDivisionError as detail:
 | 
				
			||||||
...     print 'Handling run-time error:', detail
 | 
					...     print 'Handling run-time error:', detail
 | 
				
			||||||
... 
 | 
					... 
 | 
				
			||||||
Handling run-time error: integer division or modulo by zero
 | 
					Handling run-time error: integer division or modulo by zero
 | 
				
			||||||
| 
						 | 
					@ -3619,7 +3620,7 @@ example:
 | 
				
			||||||
... 
 | 
					... 
 | 
				
			||||||
>>> try:
 | 
					>>> try:
 | 
				
			||||||
...     raise MyError(2*2)
 | 
					...     raise MyError(2*2)
 | 
				
			||||||
... except MyError, e:
 | 
					... except MyError as e:
 | 
				
			||||||
...     print 'My exception occurred, value:', e.value
 | 
					...     print 'My exception occurred, value:', e.value
 | 
				
			||||||
... 
 | 
					... 
 | 
				
			||||||
My exception occurred, value: 4
 | 
					My exception occurred, value: 4
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,7 +79,7 @@ try_stmt: ('try' ':' suite
 | 
				
			||||||
with_stmt: 'with' test [ with_var ] ':' suite
 | 
					with_stmt: 'with' test [ with_var ] ':' suite
 | 
				
			||||||
with_var: 'as' expr
 | 
					with_var: 'as' expr
 | 
				
			||||||
# NB compile.c makes sure that the default except clause is last
 | 
					# 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
 | 
					suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Backward compatibility cruft to support:
 | 
					# Backward compatibility cruft to support:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -320,7 +320,7 @@ def run_cgi(self):
 | 
				
			||||||
                    sys.stdout = save_stdout
 | 
					                    sys.stdout = save_stdout
 | 
				
			||||||
                    sys.stderr = save_stderr
 | 
					                    sys.stderr = save_stderr
 | 
				
			||||||
                    os.chdir(save_cwd)
 | 
					                    os.chdir(save_cwd)
 | 
				
			||||||
            except SystemExit, sts:
 | 
					            except SystemExit as sts:
 | 
				
			||||||
                self.log_error("CGI script exit status %s", str(sts))
 | 
					                self.log_error("CGI script exit status %s", str(sts))
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.log_message("CGI script exited OK")
 | 
					                self.log_message("CGI script exited OK")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -567,7 +567,7 @@ def _interpolate(self, section, option, rawval, vars):
 | 
				
			||||||
                value = self._KEYCRE.sub(self._interpolation_replace, value)
 | 
					                value = self._KEYCRE.sub(self._interpolation_replace, value)
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    value = value % vars
 | 
					                    value = value % vars
 | 
				
			||||||
                except KeyError, e:
 | 
					                except KeyError as e:
 | 
				
			||||||
                    raise InterpolationMissingOptionError(
 | 
					                    raise InterpolationMissingOptionError(
 | 
				
			||||||
                        option, section, rawval, e[0])
 | 
					                        option, section, rawval, e[0])
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -259,7 +259,7 @@ def _marshaled_dispatch(self, data, dispatch_method = None):
 | 
				
			||||||
            response = (response,)
 | 
					            response = (response,)
 | 
				
			||||||
            response = xmlrpclib.dumps(response, methodresponse=1,
 | 
					            response = xmlrpclib.dumps(response, methodresponse=1,
 | 
				
			||||||
                                       allow_none=self.allow_none, encoding=self.encoding)
 | 
					                                       allow_none=self.allow_none, encoding=self.encoding)
 | 
				
			||||||
        except Fault, fault:
 | 
					        except Fault as fault:
 | 
				
			||||||
            response = xmlrpclib.dumps(fault, allow_none=self.allow_none,
 | 
					            response = xmlrpclib.dumps(fault, allow_none=self.allow_none,
 | 
				
			||||||
                                       encoding=self.encoding)
 | 
					                                       encoding=self.encoding)
 | 
				
			||||||
        except:
 | 
					        except:
 | 
				
			||||||
| 
						 | 
					@ -359,7 +359,7 @@ def system_multicall(self, call_list):
 | 
				
			||||||
                # XXX A marshalling error in any response will fail the entire
 | 
					                # XXX A marshalling error in any response will fail the entire
 | 
				
			||||||
                # multicall. If someone cares they should fix this.
 | 
					                # multicall. If someone cares they should fix this.
 | 
				
			||||||
                results.append([self._dispatch(method_name, params)])
 | 
					                results.append([self._dispatch(method_name, params)])
 | 
				
			||||||
            except Fault, fault:
 | 
					            except Fault as fault:
 | 
				
			||||||
                results.append(
 | 
					                results.append(
 | 
				
			||||||
                    {'faultCode' : fault.faultCode,
 | 
					                    {'faultCode' : fault.faultCode,
 | 
				
			||||||
                     'faultString' : fault.faultString}
 | 
					                     'faultString' : fault.faultString}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -291,7 +291,7 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
 | 
				
			||||||
                format_regex = time_re.compile(format)
 | 
					                format_regex = time_re.compile(format)
 | 
				
			||||||
            # KeyError raised when a bad format is found; can be specified as
 | 
					            # KeyError raised when a bad format is found; can be specified as
 | 
				
			||||||
            # \\, in which case it was a stray % but with a space after it
 | 
					            # \\, in which case it was a stray % but with a space after it
 | 
				
			||||||
            except KeyError, err:
 | 
					            except KeyError as err:
 | 
				
			||||||
                bad_directive = err.args[0]
 | 
					                bad_directive = err.args[0]
 | 
				
			||||||
                if bad_directive == "\\":
 | 
					                if bad_directive == "\\":
 | 
				
			||||||
                    bad_directive = "%"
 | 
					                    bad_directive = "%"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,7 +87,7 @@ def handle_read (self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            data = self.recv (self.ac_in_buffer_size)
 | 
					            data = self.recv (self.ac_in_buffer_size)
 | 
				
			||||||
        except socket.error, why:
 | 
					        except socket.error as why:
 | 
				
			||||||
            self.handle_error()
 | 
					            self.handle_error()
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -220,7 +220,7 @@ def initiate_send (self):
 | 
				
			||||||
                if num_sent:
 | 
					                if num_sent:
 | 
				
			||||||
                    self.ac_out_buffer = self.ac_out_buffer[num_sent:]
 | 
					                    self.ac_out_buffer = self.ac_out_buffer[num_sent:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            except socket.error, why:
 | 
					            except socket.error as why:
 | 
				
			||||||
                self.handle_error()
 | 
					                self.handle_error()
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -119,7 +119,7 @@ def poll(timeout=0.0, map=None):
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                r, w, e = select.select(r, w, e, timeout)
 | 
					                r, w, e = select.select(r, w, e, timeout)
 | 
				
			||||||
            except select.error, err:
 | 
					            except select.error as err:
 | 
				
			||||||
                if err[0] != EINTR:
 | 
					                if err[0] != EINTR:
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
| 
						 | 
					@ -165,7 +165,7 @@ def poll2(timeout=0.0, map=None):
 | 
				
			||||||
                pollster.register(fd, flags)
 | 
					                pollster.register(fd, flags)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            r = pollster.poll(timeout)
 | 
					            r = pollster.poll(timeout)
 | 
				
			||||||
        except select.error, err:
 | 
					        except select.error as err:
 | 
				
			||||||
            if err[0] != EINTR:
 | 
					            if err[0] != EINTR:
 | 
				
			||||||
                raise
 | 
					                raise
 | 
				
			||||||
            r = []
 | 
					            r = []
 | 
				
			||||||
| 
						 | 
					@ -320,7 +320,7 @@ def accept(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            conn, addr = self.socket.accept()
 | 
					            conn, addr = self.socket.accept()
 | 
				
			||||||
            return conn, addr
 | 
					            return conn, addr
 | 
				
			||||||
        except socket.error, why:
 | 
					        except socket.error as why:
 | 
				
			||||||
            if why[0] == EWOULDBLOCK:
 | 
					            if why[0] == EWOULDBLOCK:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					@ -330,7 +330,7 @@ def send(self, data):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            result = self.socket.send(data)
 | 
					            result = self.socket.send(data)
 | 
				
			||||||
            return result
 | 
					            return result
 | 
				
			||||||
        except socket.error, why:
 | 
					        except socket.error as why:
 | 
				
			||||||
            if why[0] == EWOULDBLOCK:
 | 
					            if why[0] == EWOULDBLOCK:
 | 
				
			||||||
                return 0
 | 
					                return 0
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					@ -347,7 +347,7 @@ def recv(self, buffer_size):
 | 
				
			||||||
                return ''
 | 
					                return ''
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                return data
 | 
					                return data
 | 
				
			||||||
        except socket.error, why:
 | 
					        except socket.error as why:
 | 
				
			||||||
            # winsock sometimes throws ENOTCONN
 | 
					            # winsock sometimes throws ENOTCONN
 | 
				
			||||||
            if why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN]:
 | 
					            if why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN]:
 | 
				
			||||||
                self.handle_close()
 | 
					                self.handle_close()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ def b64decode(s, altchars=None):
 | 
				
			||||||
        s = _translate(s, {altchars[0]: '+', altchars[1]: '/'})
 | 
					        s = _translate(s, {altchars[0]: '+', altchars[1]: '/'})
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        return binascii.a2b_base64(s)
 | 
					        return binascii.a2b_base64(s)
 | 
				
			||||||
    except binascii.Error, msg:
 | 
					    except binascii.Error as msg:
 | 
				
			||||||
        # Transform this exception for consistency
 | 
					        # Transform this exception for consistency
 | 
				
			||||||
        raise TypeError(msg)
 | 
					        raise TypeError(msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -328,7 +328,7 @@ def test():
 | 
				
			||||||
    import sys, getopt
 | 
					    import sys, getopt
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        opts, args = getopt.getopt(sys.argv[1:], 'deut')
 | 
					        opts, args = getopt.getopt(sys.argv[1:], 'deut')
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        sys.stdout = sys.stderr
 | 
					        sys.stdout = sys.stderr
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
        print """usage: %s [-d|-e|-u|-t] [file|-]
 | 
					        print """usage: %s [-d|-e|-u|-t] [file|-]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -260,7 +260,7 @@ def CreateTable(self, table, columns):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            txn.commit()
 | 
					            txn.commit()
 | 
				
			||||||
            txn = None
 | 
					            txn = None
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError as dberror:
 | 
				
			||||||
            if txn:
 | 
					            if txn:
 | 
				
			||||||
                txn.abort()
 | 
					                txn.abort()
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
| 
						 | 
					@ -338,7 +338,7 @@ def CreateOrExtendTable(self, table, columns):
 | 
				
			||||||
                txn = None
 | 
					                txn = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                self.__load_column_info(table)
 | 
					                self.__load_column_info(table)
 | 
				
			||||||
            except DBError, dberror:
 | 
					            except DBError as dberror:
 | 
				
			||||||
                if txn:
 | 
					                if txn:
 | 
				
			||||||
                    txn.abort()
 | 
					                    txn.abort()
 | 
				
			||||||
                raise TableDBError, dberror[1]
 | 
					                raise TableDBError, dberror[1]
 | 
				
			||||||
| 
						 | 
					@ -407,7 +407,7 @@ def Insert(self, table, rowdict) :
 | 
				
			||||||
            txn.commit()
 | 
					            txn.commit()
 | 
				
			||||||
            txn = None
 | 
					            txn = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError as dberror:
 | 
				
			||||||
            # WIBNI we could just abort the txn and re-raise the exception?
 | 
					            # WIBNI we could just abort the txn and re-raise the exception?
 | 
				
			||||||
            # But no, because TableDBError is not related to DBError via
 | 
					            # But no, because TableDBError is not related to DBError via
 | 
				
			||||||
            # inheritance, so it would be backwards incompatible.  Do the next
 | 
					            # inheritance, so it would be backwards incompatible.  Do the next
 | 
				
			||||||
| 
						 | 
					@ -466,7 +466,7 @@ def Modify(self, table, conditions={}, mappings={}):
 | 
				
			||||||
                        txn.abort()
 | 
					                        txn.abort()
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError as dberror:
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def Delete(self, table, conditions={}):
 | 
					    def Delete(self, table, conditions={}):
 | 
				
			||||||
| 
						 | 
					@ -502,11 +502,11 @@ def Delete(self, table, conditions={}):
 | 
				
			||||||
                        pass
 | 
					                        pass
 | 
				
			||||||
                    txn.commit()
 | 
					                    txn.commit()
 | 
				
			||||||
                    txn = None
 | 
					                    txn = None
 | 
				
			||||||
                except DBError, dberror:
 | 
					                except DBError as dberror:
 | 
				
			||||||
                    if txn:
 | 
					                    if txn:
 | 
				
			||||||
                        txn.abort()
 | 
					                        txn.abort()
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError as dberror:
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -526,7 +526,7 @@ def Select(self, table, columns, conditions={}):
 | 
				
			||||||
            if columns is None:
 | 
					            if columns is None:
 | 
				
			||||||
                columns = self.__tablecolumns[table]
 | 
					                columns = self.__tablecolumns[table]
 | 
				
			||||||
            matching_rowids = self.__Select(table, columns, conditions)
 | 
					            matching_rowids = self.__Select(table, columns, conditions)
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError as dberror:
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
        # return the matches as a list of dictionaries
 | 
					        # return the matches as a list of dictionaries
 | 
				
			||||||
        return matching_rowids.values()
 | 
					        return matching_rowids.values()
 | 
				
			||||||
| 
						 | 
					@ -616,7 +616,7 @@ def cmp_conditions(atuple, btuple):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    key, data = cur.next()
 | 
					                    key, data = cur.next()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            except DBError, dberror:
 | 
					            except DBError as dberror:
 | 
				
			||||||
                if dberror[0] != DB_NOTFOUND:
 | 
					                if dberror[0] != DB_NOTFOUND:
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
| 
						 | 
					@ -636,7 +636,7 @@ def cmp_conditions(atuple, btuple):
 | 
				
			||||||
                    try:
 | 
					                    try:
 | 
				
			||||||
                        rowdata[column] = self.db.get(
 | 
					                        rowdata[column] = self.db.get(
 | 
				
			||||||
                            _data_key(table, column, rowid))
 | 
					                            _data_key(table, column, rowid))
 | 
				
			||||||
                    except DBError, dberror:
 | 
					                    except DBError as dberror:
 | 
				
			||||||
                        if dberror[0] != DB_NOTFOUND:
 | 
					                        if dberror[0] != DB_NOTFOUND:
 | 
				
			||||||
                            raise
 | 
					                            raise
 | 
				
			||||||
                        rowdata[column] = None
 | 
					                        rowdata[column] = None
 | 
				
			||||||
| 
						 | 
					@ -700,7 +700,7 @@ def Drop(self, table):
 | 
				
			||||||
            if table in self.__tablecolumns:
 | 
					            if table in self.__tablecolumns:
 | 
				
			||||||
                del self.__tablecolumns[table]
 | 
					                del self.__tablecolumns[table]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError as dberror:
 | 
				
			||||||
            if txn:
 | 
					            if txn:
 | 
				
			||||||
                txn.abort()
 | 
					                txn.abort()
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ def setUp(self):
 | 
				
			||||||
            self.homeDir = homeDir
 | 
					            self.homeDir = homeDir
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                shutil.rmtree(homeDir)
 | 
					                shutil.rmtree(homeDir)
 | 
				
			||||||
            except OSError, e:
 | 
					            except OSError as e:
 | 
				
			||||||
                # unix returns ENOENT, windows returns ESRCH
 | 
					                # unix returns ENOENT, windows returns ESRCH
 | 
				
			||||||
                if e.errno not in (errno.ENOENT, errno.ESRCH): raise
 | 
					                if e.errno not in (errno.ENOENT, errno.ESRCH): raise
 | 
				
			||||||
            os.mkdir(homeDir)
 | 
					            os.mkdir(homeDir)
 | 
				
			||||||
| 
						 | 
					@ -162,7 +162,7 @@ def test01_GetsAndPuts(self):
 | 
				
			||||||
        # set_get_returns_none() to change it.
 | 
					        # set_get_returns_none() to change it.
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            d.delete('abcd')
 | 
					            d.delete('abcd')
 | 
				
			||||||
        except db.DBNotFoundError, val:
 | 
					        except db.DBNotFoundError as val:
 | 
				
			||||||
            assert val[0] == db.DB_NOTFOUND
 | 
					            assert val[0] == db.DB_NOTFOUND
 | 
				
			||||||
            if verbose: print val
 | 
					            if verbose: print val
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -181,7 +181,7 @@ def test01_GetsAndPuts(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
 | 
					            d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
 | 
				
			||||||
        except db.DBKeyExistError, val:
 | 
					        except db.DBKeyExistError as val:
 | 
				
			||||||
            assert val[0] == db.DB_KEYEXIST
 | 
					            assert val[0] == db.DB_KEYEXIST
 | 
				
			||||||
            if verbose: print val
 | 
					            if verbose: print val
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -313,7 +313,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
 | 
				
			||||||
                print rec
 | 
					                print rec
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                rec = c.next()
 | 
					                rec = c.next()
 | 
				
			||||||
            except db.DBNotFoundError, val:
 | 
					            except db.DBNotFoundError as val:
 | 
				
			||||||
                if get_raises_error:
 | 
					                if get_raises_error:
 | 
				
			||||||
                    assert val[0] == db.DB_NOTFOUND
 | 
					                    assert val[0] == db.DB_NOTFOUND
 | 
				
			||||||
                    if verbose: print val
 | 
					                    if verbose: print val
 | 
				
			||||||
| 
						 | 
					@ -333,7 +333,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
 | 
				
			||||||
                print rec
 | 
					                print rec
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                rec = c.prev()
 | 
					                rec = c.prev()
 | 
				
			||||||
            except db.DBNotFoundError, val:
 | 
					            except db.DBNotFoundError as val:
 | 
				
			||||||
                if get_raises_error:
 | 
					                if get_raises_error:
 | 
				
			||||||
                    assert val[0] == db.DB_NOTFOUND
 | 
					                    assert val[0] == db.DB_NOTFOUND
 | 
				
			||||||
                    if verbose: print val
 | 
					                    if verbose: print val
 | 
				
			||||||
| 
						 | 
					@ -357,7 +357,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            n = c.set('bad key')
 | 
					            n = c.set('bad key')
 | 
				
			||||||
        except db.DBNotFoundError, val:
 | 
					        except db.DBNotFoundError as val:
 | 
				
			||||||
            assert val[0] == db.DB_NOTFOUND
 | 
					            assert val[0] == db.DB_NOTFOUND
 | 
				
			||||||
            if verbose: print val
 | 
					            if verbose: print val
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -371,7 +371,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            n = c.get_both('0404', 'bad data')
 | 
					            n = c.get_both('0404', 'bad data')
 | 
				
			||||||
        except db.DBNotFoundError, val:
 | 
					        except db.DBNotFoundError as val:
 | 
				
			||||||
            assert val[0] == db.DB_NOTFOUND
 | 
					            assert val[0] == db.DB_NOTFOUND
 | 
				
			||||||
            if verbose: print val
 | 
					            if verbose: print val
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -399,7 +399,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
 | 
				
			||||||
        c.delete()
 | 
					        c.delete()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            rec = c.current()
 | 
					            rec = c.current()
 | 
				
			||||||
        except db.DBKeyEmptyError, val:
 | 
					        except db.DBKeyEmptyError as val:
 | 
				
			||||||
            if get_raises_error:
 | 
					            if get_raises_error:
 | 
				
			||||||
                assert val[0] == db.DB_KEYEMPTY
 | 
					                assert val[0] == db.DB_KEYEMPTY
 | 
				
			||||||
                if verbose: print val
 | 
					                if verbose: print val
 | 
				
			||||||
| 
						 | 
					@ -445,7 +445,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
 | 
				
			||||||
                          method
 | 
					                          method
 | 
				
			||||||
                # a bug may cause a NULL pointer dereference...
 | 
					                # a bug may cause a NULL pointer dereference...
 | 
				
			||||||
                getattr(c, method)(*args)
 | 
					                getattr(c, method)(*args)
 | 
				
			||||||
            except db.DBError, val:
 | 
					            except db.DBError as val:
 | 
				
			||||||
                assert val[0] == 0
 | 
					                assert val[0] == 0
 | 
				
			||||||
                if verbose: print val
 | 
					                if verbose: print val
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					@ -730,7 +730,7 @@ def test08_TxnLateUse(self):
 | 
				
			||||||
        txn.abort()
 | 
					        txn.abort()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            txn.abort()
 | 
					            txn.abort()
 | 
				
			||||||
        except db.DBError, e:
 | 
					        except db.DBError as e:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            raise RuntimeError, "DBTxn.abort() called after DB_TXN no longer valid w/o an exception"
 | 
					            raise RuntimeError, "DBTxn.abort() called after DB_TXN no longer valid w/o an exception"
 | 
				
			||||||
| 
						 | 
					@ -739,7 +739,7 @@ def test08_TxnLateUse(self):
 | 
				
			||||||
        txn.commit()
 | 
					        txn.commit()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            txn.commit()
 | 
					            txn.commit()
 | 
				
			||||||
        except db.DBError, e:
 | 
					        except db.DBError as e:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            raise RuntimeError, "DBTxn.commit() called after DB_TXN no longer valid w/o an exception"
 | 
					            raise RuntimeError, "DBTxn.commit() called after DB_TXN no longer valid w/o an exception"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -234,7 +234,7 @@ def my_compare (a, b):
 | 
				
			||||||
            self.db.set_bt_compare (my_compare)
 | 
					            self.db.set_bt_compare (my_compare)
 | 
				
			||||||
            assert False, "this set should fail"
 | 
					            assert False, "this set should fail"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except RuntimeError, msg:
 | 
					        except RuntimeError as msg:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_suite ():
 | 
					def test_suite ():
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    # For Pythons w/distutils pybsddb
 | 
					    # For Pythons w/distutils pybsddb
 | 
				
			||||||
    from bsddb3 import db
 | 
					    from bsddb3 import db
 | 
				
			||||||
except ImportError, e:
 | 
					except ImportError as e:
 | 
				
			||||||
    # For Python 2.3
 | 
					    # For Python 2.3
 | 
				
			||||||
    from bsddb import db
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ def _base_test_pickle_DBError(self, pickle):
 | 
				
			||||||
        assert self.db['spam'] == 'eggs'
 | 
					        assert self.db['spam'] == 'eggs'
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE)
 | 
					            self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE)
 | 
				
			||||||
        except db.DBError, egg:
 | 
					        except db.DBError as egg:
 | 
				
			||||||
            pickledEgg = pickle.dumps(egg)
 | 
					            pickledEgg = pickle.dumps(egg)
 | 
				
			||||||
            #print repr(pickledEgg)
 | 
					            #print repr(pickledEgg)
 | 
				
			||||||
            rottenEgg = pickle.loads(pickledEgg)
 | 
					            rottenEgg = pickle.loads(pickledEgg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,7 @@ def setUp(self):
 | 
				
			||||||
    def tearDown(self):
 | 
					    def tearDown(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            os.remove(self.filename)
 | 
					            os.remove(self.filename)
 | 
				
			||||||
        except OSError, e:
 | 
					        except OSError as e:
 | 
				
			||||||
            if e.errno != errno.EEXIST: raise
 | 
					            if e.errno != errno.EEXIST: raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test01_basic(self):
 | 
					    def test01_basic(self):
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ def test01_basic(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            data = d[0]  # This should raise a KeyError!?!?!
 | 
					            data = d[0]  # This should raise a KeyError!?!?!
 | 
				
			||||||
        except db.DBInvalidArgError, val:
 | 
					        except db.DBInvalidArgError as val:
 | 
				
			||||||
            assert val[0] == db.EINVAL
 | 
					            assert val[0] == db.EINVAL
 | 
				
			||||||
            if verbose: print val
 | 
					            if verbose: print val
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,7 @@ def test01_basic(self):
 | 
				
			||||||
        # test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
 | 
					        # test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            d.has_key(0)
 | 
					            d.has_key(0)
 | 
				
			||||||
        except db.DBError, val:
 | 
					        except db.DBError as val:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.fail("has_key did not raise a proper exception")
 | 
					            self.fail("has_key did not raise a proper exception")
 | 
				
			||||||
| 
						 | 
					@ -86,7 +86,7 @@ def test01_basic(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            data = d.get(100)
 | 
					            data = d.get(100)
 | 
				
			||||||
        except db.DBNotFoundError, val:
 | 
					        except db.DBNotFoundError as val:
 | 
				
			||||||
            if get_returns_none:
 | 
					            if get_returns_none:
 | 
				
			||||||
                self.fail("unexpected exception")
 | 
					                self.fail("unexpected exception")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -177,7 +177,7 @@ def test01_basic(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            d.get(99)
 | 
					            d.get(99)
 | 
				
			||||||
        except db.DBKeyEmptyError, val:
 | 
					        except db.DBKeyEmptyError as val:
 | 
				
			||||||
            if get_returns_none:
 | 
					            if get_returns_none:
 | 
				
			||||||
                self.fail("unexpected DBKeyEmptyError exception")
 | 
					                self.fail("unexpected DBKeyEmptyError exception")
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					@ -267,7 +267,7 @@ def test03_FixedLength(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:                    # this one will fail
 | 
					        try:                    # this one will fail
 | 
				
			||||||
            d.append('bad' * 20)
 | 
					            d.append('bad' * 20)
 | 
				
			||||||
        except db.DBInvalidArgError, val:
 | 
					        except db.DBInvalidArgError as val:
 | 
				
			||||||
            assert val[0] == db.EINVAL
 | 
					            assert val[0] == db.EINVAL
 | 
				
			||||||
            if verbose: print val
 | 
					            if verbose: print val
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,7 @@ def setUp(self):
 | 
				
			||||||
        self.homeDir = homeDir
 | 
					        self.homeDir = homeDir
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            os.mkdir(homeDir)
 | 
					            os.mkdir(homeDir)
 | 
				
			||||||
        except OSError, e:
 | 
					        except OSError as e:
 | 
				
			||||||
            if e.errno != errno.EEXIST: raise
 | 
					            if e.errno != errno.EEXIST: raise
 | 
				
			||||||
        self.env = db.DBEnv()
 | 
					        self.env = db.DBEnv()
 | 
				
			||||||
        self.setEnvOpts()
 | 
					        self.setEnvOpts()
 | 
				
			||||||
| 
						 | 
					@ -247,7 +247,7 @@ def writerThread(self, d, howMany, writerNum):
 | 
				
			||||||
        # flush them
 | 
					        # flush them
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            dbutils.DeadlockWrap(d.sync, max_retries=12)
 | 
					            dbutils.DeadlockWrap(d.sync, max_retries=12)
 | 
				
			||||||
        except db.DBIncompleteError, val:
 | 
					        except db.DBIncompleteError as val:
 | 
				
			||||||
            if verbose:
 | 
					            if verbose:
 | 
				
			||||||
                print "could not complete sync()..."
 | 
					                print "could not complete sync()..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -360,7 +360,7 @@ def doWrite(self, d, name, start, stop):
 | 
				
			||||||
                        print "%s: records %d - %d finished" % (name, start, x)
 | 
					                        print "%s: records %d - %d finished" % (name, start, x)
 | 
				
			||||||
                txn.commit()
 | 
					                txn.commit()
 | 
				
			||||||
                finished = True
 | 
					                finished = True
 | 
				
			||||||
            except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
 | 
					            except (db.DBLockDeadlockError, db.DBLockNotGrantedError) as val:
 | 
				
			||||||
                if verbose:
 | 
					                if verbose:
 | 
				
			||||||
                    print "%s: Aborting transaction (%s)" % (name, val[1])
 | 
					                    print "%s: Aborting transaction (%s)" % (name, val[1])
 | 
				
			||||||
                txn.abort()
 | 
					                txn.abort()
 | 
				
			||||||
| 
						 | 
					@ -398,7 +398,7 @@ def writerThread(self, d, howMany, writerNum):
 | 
				
			||||||
                finished = True
 | 
					                finished = True
 | 
				
			||||||
                if verbose:
 | 
					                if verbose:
 | 
				
			||||||
                    print "%s: deleted records %s" % (name, recs)
 | 
					                    print "%s: deleted records %s" % (name, recs)
 | 
				
			||||||
            except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
 | 
					            except (db.DBLockDeadlockError, db.DBLockNotGrantedError) as val:
 | 
				
			||||||
                if verbose:
 | 
					                if verbose:
 | 
				
			||||||
                    print "%s: Aborting transaction (%s)" % (name, val[1])
 | 
					                    print "%s: Aborting transaction (%s)" % (name, val[1])
 | 
				
			||||||
                txn.abort()
 | 
					                txn.abort()
 | 
				
			||||||
| 
						 | 
					@ -428,7 +428,7 @@ def readerThread(self, d, readerNum):
 | 
				
			||||||
                    c.close()
 | 
					                    c.close()
 | 
				
			||||||
                    txn.commit()
 | 
					                    txn.commit()
 | 
				
			||||||
                    finished = True
 | 
					                    finished = True
 | 
				
			||||||
                except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
 | 
					                except (db.DBLockDeadlockError, db.DBLockNotGrantedError) as val:
 | 
				
			||||||
                    if verbose:
 | 
					                    if verbose:
 | 
				
			||||||
                        print "%s: Aborting transaction (%s)" % (name, val[1])
 | 
					                        print "%s: Aborting transaction (%s)" % (name, val[1])
 | 
				
			||||||
                    c.close()
 | 
					                    c.close()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -982,7 +982,7 @@ def print_directory():
 | 
				
			||||||
    print "<H3>Current Working Directory:</H3>"
 | 
					    print "<H3>Current Working Directory:</H3>"
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        pwd = os.getcwd()
 | 
					        pwd = os.getcwd()
 | 
				
			||||||
    except os.error, msg:
 | 
					    except os.error as msg:
 | 
				
			||||||
        print "os.error:", escape(str(msg))
 | 
					        print "os.error:", escape(str(msg))
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print escape(pwd)
 | 
					        print escape(pwd)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    from _codecs import *
 | 
					    from _codecs import *
 | 
				
			||||||
except ImportError, why:
 | 
					except ImportError as why:
 | 
				
			||||||
    raise SystemError('Failed to load the builtin codecs: %s' % why)
 | 
					    raise SystemError('Failed to load the builtin codecs: %s' % why)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE",
 | 
					__all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE",
 | 
				
			||||||
| 
						 | 
					@ -422,7 +422,7 @@ def read(self, size=-1, chars=-1, firstline=False):
 | 
				
			||||||
            data = self.bytebuffer + newdata
 | 
					            data = self.bytebuffer + newdata
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                newchars, decodedbytes = self.decode(data, self.errors)
 | 
					                newchars, decodedbytes = self.decode(data, self.errors)
 | 
				
			||||||
            except UnicodeDecodeError, exc:
 | 
					            except UnicodeDecodeError as exc:
 | 
				
			||||||
                if firstline:
 | 
					                if firstline:
 | 
				
			||||||
                    newchars, decodedbytes = self.decode(data[:exc.start], self.errors)
 | 
					                    newchars, decodedbytes = self.decode(data[:exc.start], self.errors)
 | 
				
			||||||
                    lines = newchars.splitlines(True)
 | 
					                    lines = newchars.splitlines(True)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,18 +80,18 @@ def _maybe_compile(compiler, source, filename, symbol):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        code = compiler(source, filename, symbol)
 | 
					        code = compiler(source, filename, symbol)
 | 
				
			||||||
    except SyntaxError, err:
 | 
					    except SyntaxError as err:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        code1 = compiler(source + "\n", filename, symbol)
 | 
					        code1 = compiler(source + "\n", filename, symbol)
 | 
				
			||||||
    except SyntaxError, err1:
 | 
					    except SyntaxError as e:
 | 
				
			||||||
        pass
 | 
					        err1 = e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        code2 = compiler(source + "\n\n", filename, symbol)
 | 
					        code2 = compiler(source + "\n\n", filename, symbol)
 | 
				
			||||||
    except SyntaxError, err2:
 | 
					    except SyntaxError as e:
 | 
				
			||||||
        pass
 | 
					        err2 = e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if code:
 | 
					    if code:
 | 
				
			||||||
        return code
 | 
					        return code
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,12 +65,12 @@ def compile_dir(dir, maxlevels=10, ddir=None,
 | 
				
			||||||
                    ok = py_compile.compile(fullname, None, dfile, True)
 | 
					                    ok = py_compile.compile(fullname, None, dfile, True)
 | 
				
			||||||
                except KeyboardInterrupt:
 | 
					                except KeyboardInterrupt:
 | 
				
			||||||
                    raise KeyboardInterrupt
 | 
					                    raise KeyboardInterrupt
 | 
				
			||||||
                except py_compile.PyCompileError,err:
 | 
					                except py_compile.PyCompileError as err:
 | 
				
			||||||
                    if quiet:
 | 
					                    if quiet:
 | 
				
			||||||
                        print 'Compiling', fullname, '...'
 | 
					                        print 'Compiling', fullname, '...'
 | 
				
			||||||
                    print err.msg
 | 
					                    print err.msg
 | 
				
			||||||
                    success = 0
 | 
					                    success = 0
 | 
				
			||||||
                except IOError, e:
 | 
					                except IOError as e:
 | 
				
			||||||
                    print "Sorry", e
 | 
					                    print "Sorry", e
 | 
				
			||||||
                    success = 0
 | 
					                    success = 0
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
| 
						 | 
					@ -109,7 +109,7 @@ def main():
 | 
				
			||||||
    import getopt
 | 
					    import getopt
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:')
 | 
					        opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:')
 | 
				
			||||||
    except getopt.error, msg:
 | 
					    except getopt.error as msg:
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
        print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
 | 
					        print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
 | 
				
			||||||
              "[-x regexp] [directory ...]"
 | 
					              "[-x regexp] [directory ...]"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -227,7 +227,7 @@ def checkClass(self):
 | 
				
			||||||
            assert getattr(self, 'NameFinder')
 | 
					            assert getattr(self, 'NameFinder')
 | 
				
			||||||
            assert getattr(self, 'FunctionGen')
 | 
					            assert getattr(self, 'FunctionGen')
 | 
				
			||||||
            assert getattr(self, 'ClassGen')
 | 
					            assert getattr(self, 'ClassGen')
 | 
				
			||||||
        except AssertionError, msg:
 | 
					        except AssertionError as msg:
 | 
				
			||||||
            intro = "Bad class construction for %s" % self.__class__.__name__
 | 
					            intro = "Bad class construction for %s" % self.__class__.__name__
 | 
				
			||||||
            raise AssertionError, intro
 | 
					            raise AssertionError, intro
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ def __exit__(self, type, value, traceback):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.gen.throw(type, value, traceback)
 | 
					                self.gen.throw(type, value, traceback)
 | 
				
			||||||
                raise RuntimeError("generator didn't stop after throw()")
 | 
					                raise RuntimeError("generator didn't stop after throw()")
 | 
				
			||||||
            except StopIteration, exc:
 | 
					            except StopIteration as exc:
 | 
				
			||||||
                # Suppress the exception *unless* it's the same exception that
 | 
					                # Suppress the exception *unless* it's the same exception that
 | 
				
			||||||
                # was passed to throw().  This prevents a StopIteration
 | 
					                # was passed to throw().  This prevents a StopIteration
 | 
				
			||||||
                # raised inside the "with" statement from being suppressed
 | 
					                # raised inside the "with" statement from being suppressed
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ def __init__(self):
 | 
				
			||||||
    def _validate(self):
 | 
					    def _validate(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            _Dialect(self)
 | 
					            _Dialect(self)
 | 
				
			||||||
        except TypeError, e:
 | 
					        except TypeError as e:
 | 
				
			||||||
            # We do this for compatibility with py2.3
 | 
					            # We do this for compatibility with py2.3
 | 
				
			||||||
            raise Error(str(e))
 | 
					            raise Error(str(e))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -148,7 +148,7 @@ def framework_find(fn, executable_path=None, env=None):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        return dyld_find(fn, executable_path=executable_path, env=env)
 | 
					        return dyld_find(fn, executable_path=executable_path, env=env)
 | 
				
			||||||
    except ValueError, e:
 | 
					    except ValueError as e:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
    fmwk_index = fn.rfind('.framework')
 | 
					    fmwk_index = fn.rfind('.framework')
 | 
				
			||||||
    if fmwk_index == -1:
 | 
					    if fmwk_index == -1:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,12 +57,12 @@ def get_tests(package, mask, verbosity):
 | 
				
			||||||
    for modname in find_package_modules(package, mask):
 | 
					    for modname in find_package_modules(package, mask):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            mod = __import__(modname, globals(), locals(), ['*'])
 | 
					            mod = __import__(modname, globals(), locals(), ['*'])
 | 
				
			||||||
        except ResourceDenied, detail:
 | 
					        except ResourceDenied as detail:
 | 
				
			||||||
            skipped.append(modname)
 | 
					            skipped.append(modname)
 | 
				
			||||||
            if verbosity > 1:
 | 
					            if verbosity > 1:
 | 
				
			||||||
                print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
 | 
					                print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
        except Exception, detail:
 | 
					        except Exception as detail:
 | 
				
			||||||
            print >> sys.stderr, "Warning: could not import %s: %s" % (modname, detail)
 | 
					            print >> sys.stderr, "Warning: could not import %s: %s" % (modname, detail)
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
        for name in dir(mod):
 | 
					        for name in dir(mod):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -191,7 +191,7 @@ class X(Structure):
 | 
				
			||||||
    def get_except(self, func, *args, **kw):
 | 
					    def get_except(self, func, *args, **kw):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            func(*args, **kw)
 | 
					            func(*args, **kw)
 | 
				
			||||||
        except Exception, detail:
 | 
					        except Exception as detail:
 | 
				
			||||||
            return detail.__class__, str(detail)
 | 
					            return detail.__class__, str(detail)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_mixed_1(self):
 | 
					    def test_mixed_1(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -313,7 +313,7 @@ class Person(Structure):
 | 
				
			||||||
    def get_except(self, func, *args):
 | 
					    def get_except(self, func, *args):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            func(*args)
 | 
					            func(*args)
 | 
				
			||||||
        except Exception, detail:
 | 
					        except Exception as detail:
 | 
				
			||||||
            return detail.__class__, str(detail)
 | 
					            return detail.__class__, str(detail)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -388,7 +388,7 @@ class Recursive(Structure):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            Recursive._fields_ = [("next", Recursive)]
 | 
					            Recursive._fields_ = [("next", Recursive)]
 | 
				
			||||||
        except AttributeError, details:
 | 
					        except AttributeError as details:
 | 
				
			||||||
            self.failUnless("Structure or union cannot contain itself" in
 | 
					            self.failUnless("Structure or union cannot contain itself" in
 | 
				
			||||||
                            str(details))
 | 
					                            str(details))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -405,7 +405,7 @@ class Second(Structure):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            Second._fields_ = [("first", First)]
 | 
					            Second._fields_ = [("first", First)]
 | 
				
			||||||
        except AttributeError, details:
 | 
					        except AttributeError as details:
 | 
				
			||||||
            self.failUnless("_fields_ is final" in
 | 
					            self.failUnless("_fields_ is final" in
 | 
				
			||||||
                            str(details))
 | 
					                            str(details))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,12 +60,12 @@ def _findLib_gcc(name):
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                os.unlink(outfile)
 | 
					                os.unlink(outfile)
 | 
				
			||||||
            except OSError, e:
 | 
					            except OSError as e:
 | 
				
			||||||
                if e.errno != errno.ENOENT:
 | 
					                if e.errno != errno.ENOENT:
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                os.unlink(ccout)
 | 
					                os.unlink(ccout)
 | 
				
			||||||
            except OSError, e:
 | 
					            except OSError as e:
 | 
				
			||||||
                if e.errno != errno.ENOENT:
 | 
					                if e.errno != errno.ENOENT:
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
        res = re.search(expr, trace)
 | 
					        res = re.search(expr, trace)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@ def dis(x=None):
 | 
				
			||||||
                print "Disassembly of %s:" % name
 | 
					                print "Disassembly of %s:" % name
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    dis(x1)
 | 
					                    dis(x1)
 | 
				
			||||||
                except TypeError, msg:
 | 
					                except TypeError as msg:
 | 
				
			||||||
                    print "Sorry:", msg
 | 
					                    print "Sorry:", msg
 | 
				
			||||||
                print
 | 
					                print
 | 
				
			||||||
    elif hasattr(x, 'co_code'):
 | 
					    elif hasattr(x, 'co_code'):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,7 +115,7 @@ def compile(self, sources,
 | 
				
			||||||
                # This needs to be compiled to a .res file -- do it now.
 | 
					                # This needs to be compiled to a .res file -- do it now.
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    self.spawn (["brcc32", "-fo", obj, src])
 | 
					                    self.spawn (["brcc32", "-fo", obj, src])
 | 
				
			||||||
                except DistutilsExecError, msg:
 | 
					                except DistutilsExecError as msg:
 | 
				
			||||||
                    raise CompileError, msg
 | 
					                    raise CompileError, msg
 | 
				
			||||||
                continue # the 'for' loop
 | 
					                continue # the 'for' loop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -139,7 +139,7 @@ def compile(self, sources,
 | 
				
			||||||
                self.spawn ([self.cc] + compile_opts + pp_opts +
 | 
					                self.spawn ([self.cc] + compile_opts + pp_opts +
 | 
				
			||||||
                            [input_opt, output_opt] +
 | 
					                            [input_opt, output_opt] +
 | 
				
			||||||
                            extra_postargs + [src])
 | 
					                            extra_postargs + [src])
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return objects
 | 
					        return objects
 | 
				
			||||||
| 
						 | 
					@ -164,7 +164,7 @@ def create_static_lib (self,
 | 
				
			||||||
                pass                    # XXX what goes here?
 | 
					                pass                    # XXX what goes here?
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn ([self.lib] + lib_args)
 | 
					                self.spawn ([self.lib] + lib_args)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise LibError, msg
 | 
					                raise LibError, msg
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            log.debug("skipping %s (up-to-date)", output_filename)
 | 
					            log.debug("skipping %s (up-to-date)", output_filename)
 | 
				
			||||||
| 
						 | 
					@ -298,7 +298,7 @@ def link (self,
 | 
				
			||||||
            self.mkpath (os.path.dirname (output_filename))
 | 
					            self.mkpath (os.path.dirname (output_filename))
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn ([self.linker] + ld_args)
 | 
					                self.spawn ([self.linker] + ld_args)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise LinkError, msg
 | 
					                raise LinkError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -391,7 +391,7 @@ def preprocess (self,
 | 
				
			||||||
                self.mkpath(os.path.dirname(output_file))
 | 
					                self.mkpath(os.path.dirname(output_file))
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn(pp_args)
 | 
					                self.spawn(pp_args)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                print msg
 | 
					                print msg
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -284,11 +284,11 @@ def post_to_server(self, data, auth=None):
 | 
				
			||||||
        data = ''
 | 
					        data = ''
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            result = opener.open(req)
 | 
					            result = opener.open(req)
 | 
				
			||||||
        except urllib2.HTTPError, e:
 | 
					        except urllib2.HTTPError as e:
 | 
				
			||||||
            if self.show_response:
 | 
					            if self.show_response:
 | 
				
			||||||
                data = e.fp.read()
 | 
					                data = e.fp.read()
 | 
				
			||||||
            result = e.code, e.msg
 | 
					            result = e.code, e.msg
 | 
				
			||||||
        except urllib2.URLError, e:
 | 
					        except urllib2.URLError as e:
 | 
				
			||||||
            result = 500, str(e)
 | 
					            result = 500, str(e)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            if self.show_response:
 | 
					            if self.show_response:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -333,7 +333,7 @@ def read_template (self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.filelist.process_template_line(line)
 | 
					                self.filelist.process_template_line(line)
 | 
				
			||||||
            except DistutilsTemplateError, msg:
 | 
					            except DistutilsTemplateError as msg:
 | 
				
			||||||
                self.warn("%s, line %d: %s" % (template.filename,
 | 
					                self.warn("%s, line %d: %s" % (template.filename,
 | 
				
			||||||
                                               template.current_line,
 | 
					                                               template.current_line,
 | 
				
			||||||
                                               msg))
 | 
					                                               msg))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,7 +184,7 @@ def upload_file(self, command, pyversion, filename):
 | 
				
			||||||
            http.putheader('Authorization', auth)
 | 
					            http.putheader('Authorization', auth)
 | 
				
			||||||
            http.endheaders()
 | 
					            http.endheaders()
 | 
				
			||||||
            http.send(body)
 | 
					            http.send(body)
 | 
				
			||||||
        except socket.error, e:
 | 
					        except socket.error as e:
 | 
				
			||||||
            self.announce(str(e), log.ERROR)
 | 
					            self.announce(str(e), log.ERROR)
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,7 +110,7 @@ class found in 'cmdclass' is used in place of the default, which is
 | 
				
			||||||
    # (ie. everything except distclass) to initialize it
 | 
					    # (ie. everything except distclass) to initialize it
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        _setup_distribution = dist = klass(attrs)
 | 
					        _setup_distribution = dist = klass(attrs)
 | 
				
			||||||
    except DistutilsSetupError, msg:
 | 
					    except DistutilsSetupError as msg:
 | 
				
			||||||
        if 'name' not in attrs:
 | 
					        if 'name' not in attrs:
 | 
				
			||||||
            raise SystemExit, "error in %s setup command: %s" % \
 | 
					            raise SystemExit, "error in %s setup command: %s" % \
 | 
				
			||||||
                  (attrs['name'], msg)
 | 
					                  (attrs['name'], msg)
 | 
				
			||||||
| 
						 | 
					@ -135,7 +135,7 @@ class found in 'cmdclass' is used in place of the default, which is
 | 
				
			||||||
    # fault, so turn them into SystemExit to suppress tracebacks.
 | 
					    # fault, so turn them into SystemExit to suppress tracebacks.
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        ok = dist.parse_command_line()
 | 
					        ok = dist.parse_command_line()
 | 
				
			||||||
    except DistutilsArgError, msg:
 | 
					    except DistutilsArgError as msg:
 | 
				
			||||||
        raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
 | 
					        raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if DEBUG:
 | 
					    if DEBUG:
 | 
				
			||||||
| 
						 | 
					@ -151,7 +151,7 @@ class found in 'cmdclass' is used in place of the default, which is
 | 
				
			||||||
            dist.run_commands()
 | 
					            dist.run_commands()
 | 
				
			||||||
        except KeyboardInterrupt:
 | 
					        except KeyboardInterrupt:
 | 
				
			||||||
            raise SystemExit, "interrupted"
 | 
					            raise SystemExit, "interrupted"
 | 
				
			||||||
        except (IOError, os.error), exc:
 | 
					        except (IOError, os.error) as exc:
 | 
				
			||||||
            error = grok_environment_error(exc)
 | 
					            error = grok_environment_error(exc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if DEBUG:
 | 
					            if DEBUG:
 | 
				
			||||||
| 
						 | 
					@ -161,7 +161,7 @@ class found in 'cmdclass' is used in place of the default, which is
 | 
				
			||||||
                raise SystemExit, error
 | 
					                raise SystemExit, error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except (DistutilsError,
 | 
					        except (DistutilsError,
 | 
				
			||||||
                CCompilerError), msg:
 | 
					                CCompilerError) as msg:
 | 
				
			||||||
            if DEBUG:
 | 
					            if DEBUG:
 | 
				
			||||||
                raise
 | 
					                raise
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,13 +142,13 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
 | 
				
			||||||
            # gcc needs '.res' and '.rc' compiled to object files !!!
 | 
					            # gcc needs '.res' and '.rc' compiled to object files !!!
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn(["windres", "-i", src, "-o", obj])
 | 
					                self.spawn(["windres", "-i", src, "-o", obj])
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
        else: # for other files use the C-compiler
 | 
					        else: # for other files use the C-compiler
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
 | 
					                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
 | 
				
			||||||
                           extra_postargs)
 | 
					                           extra_postargs)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def link (self,
 | 
					    def link (self,
 | 
				
			||||||
| 
						 | 
					@ -379,7 +379,7 @@ def check_config_h():
 | 
				
			||||||
        s = f.read()
 | 
					        s = f.read()
 | 
				
			||||||
        f.close()
 | 
					        f.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    except IOError, exc:
 | 
					    except IOError as exc:
 | 
				
			||||||
        # if we can't read this file, we cannot say it is wrong
 | 
					        # if we can't read this file, we cannot say it is wrong
 | 
				
			||||||
        # the compiler will complain later about this file as missing
 | 
					        # the compiler will complain later about this file as missing
 | 
				
			||||||
        return (CONFIG_H_UNCERTAIN,
 | 
					        return (CONFIG_H_UNCERTAIN,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                os.mkdir(head)
 | 
					                os.mkdir(head)
 | 
				
			||||||
                created_dirs.append(head)
 | 
					                created_dirs.append(head)
 | 
				
			||||||
            except OSError, exc:
 | 
					            except OSError as exc:
 | 
				
			||||||
                raise DistutilsFileError, \
 | 
					                raise DistutilsFileError, \
 | 
				
			||||||
                      "could not create '%s': %s" % (head, exc[-1])
 | 
					                      "could not create '%s': %s" % (head, exc[-1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,7 +142,8 @@ def copy_tree (src, dst,
 | 
				
			||||||
              "cannot copy tree '%s': not a directory" % src
 | 
					              "cannot copy tree '%s': not a directory" % src
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        names = os.listdir(src)
 | 
					        names = os.listdir(src)
 | 
				
			||||||
    except os.error, (errno, errstr):
 | 
					    except os.error as e:
 | 
				
			||||||
 | 
					        (errno, errstr) = e
 | 
				
			||||||
        if dry_run:
 | 
					        if dry_run:
 | 
				
			||||||
            names = []
 | 
					            names = []
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -209,7 +210,7 @@ def remove_tree (directory, verbose=0, dry_run=0):
 | 
				
			||||||
            abspath = os.path.abspath(cmd[1])
 | 
					            abspath = os.path.abspath(cmd[1])
 | 
				
			||||||
            if abspath in _path_created:
 | 
					            if abspath in _path_created:
 | 
				
			||||||
                del _path_created[abspath]
 | 
					                del _path_created[abspath]
 | 
				
			||||||
        except (IOError, OSError), exc:
 | 
					        except (IOError, OSError) as exc:
 | 
				
			||||||
            log.warn(grok_environment_error(
 | 
					            log.warn(grok_environment_error(
 | 
				
			||||||
                    exc, "error removing %s: " % directory))
 | 
					                    exc, "error removing %s: " % directory))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -398,7 +398,7 @@ def parse_config_files (self, filenames=None):
 | 
				
			||||||
                        setattr(self, opt, strtobool(val))
 | 
					                        setattr(self, opt, strtobool(val))
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        setattr(self, opt, val)
 | 
					                        setattr(self, opt, val)
 | 
				
			||||||
                except ValueError, msg:
 | 
					                except ValueError as msg:
 | 
				
			||||||
                    raise DistutilsOptionError, msg
 | 
					                    raise DistutilsOptionError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # parse_config_files ()
 | 
					    # parse_config_files ()
 | 
				
			||||||
| 
						 | 
					@ -515,7 +515,7 @@ def _parse_command_opts (self, parser, args):
 | 
				
			||||||
        # it takes.
 | 
					        # it takes.
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            cmd_class = self.get_command_class(command)
 | 
					            cmd_class = self.get_command_class(command)
 | 
				
			||||||
        except DistutilsModuleError, msg:
 | 
					        except DistutilsModuleError as msg:
 | 
				
			||||||
            raise DistutilsArgError, msg
 | 
					            raise DistutilsArgError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Require that the command class be derived from Command -- want
 | 
					        # Require that the command class be derived from Command -- want
 | 
				
			||||||
| 
						 | 
					@ -917,7 +917,7 @@ def _set_command_options (self, command_obj, option_dict=None):
 | 
				
			||||||
                    raise DistutilsOptionError, \
 | 
					                    raise DistutilsOptionError, \
 | 
				
			||||||
                          ("error in %s: command '%s' has no such option '%s'"
 | 
					                          ("error in %s: command '%s' has no such option '%s'"
 | 
				
			||||||
                           % (source, command_name, option))
 | 
					                           % (source, command_name, option))
 | 
				
			||||||
            except ValueError, msg:
 | 
					            except ValueError as msg:
 | 
				
			||||||
                raise DistutilsOptionError, msg
 | 
					                raise DistutilsOptionError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def reinitialize_command (self, command, reinit_subcommands=0):
 | 
					    def reinitialize_command (self, command, reinit_subcommands=0):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,13 +79,13 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
 | 
				
			||||||
            # gcc requires '.rc' compiled to binary ('.res') files !!!
 | 
					            # gcc requires '.rc' compiled to binary ('.res') files !!!
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn(["rc", "-r", src])
 | 
					                self.spawn(["rc", "-r", src])
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
        else: # for other files use the C-compiler
 | 
					        else: # for other files use the C-compiler
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
 | 
					                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
 | 
				
			||||||
                           extra_postargs)
 | 
					                           extra_postargs)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def link (self,
 | 
					    def link (self,
 | 
				
			||||||
| 
						 | 
					@ -275,7 +275,7 @@ def check_config_h():
 | 
				
			||||||
        s = f.read()
 | 
					        s = f.read()
 | 
				
			||||||
        f.close()
 | 
					        f.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    except IOError, exc:
 | 
					    except IOError as exc:
 | 
				
			||||||
        # if we can't read this file, we cannot say it is wrong
 | 
					        # if we can't read this file, we cannot say it is wrong
 | 
				
			||||||
        # the compiler will complain later about this file as missing
 | 
					        # the compiler will complain later about this file as missing
 | 
				
			||||||
        return (CONFIG_H_UNCERTAIN,
 | 
					        return (CONFIG_H_UNCERTAIN,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -256,7 +256,7 @@ def getopt (self, args=None, object=None):
 | 
				
			||||||
        short_opts = string.join(self.short_opts)
 | 
					        short_opts = string.join(self.short_opts)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            opts, args = getopt.getopt(args, short_opts, self.long_opts)
 | 
					            opts, args = getopt.getopt(args, short_opts, self.long_opts)
 | 
				
			||||||
        except getopt.error, msg:
 | 
					        except getopt.error as msg:
 | 
				
			||||||
            raise DistutilsArgError, msg
 | 
					            raise DistutilsArgError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for opt, val in opts:
 | 
					        for opt, val in opts:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,27 +32,31 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            fsrc = open(src, 'rb')
 | 
					            fsrc = open(src, 'rb')
 | 
				
			||||||
        except os.error, (errno, errstr):
 | 
					        except os.error as e:
 | 
				
			||||||
 | 
					            (errno, errstr) = e
 | 
				
			||||||
            raise DistutilsFileError, \
 | 
					            raise DistutilsFileError, \
 | 
				
			||||||
                  "could not open '%s': %s" % (src, errstr)
 | 
					                  "could not open '%s': %s" % (src, errstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if os.path.exists(dst):
 | 
					        if os.path.exists(dst):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                os.unlink(dst)
 | 
					                os.unlink(dst)
 | 
				
			||||||
            except os.error, (errno, errstr):
 | 
					            except os.error as e:
 | 
				
			||||||
 | 
					                (errno, errstr) = e
 | 
				
			||||||
                raise DistutilsFileError, \
 | 
					                raise DistutilsFileError, \
 | 
				
			||||||
                      "could not delete '%s': %s" % (dst, errstr)
 | 
					                      "could not delete '%s': %s" % (dst, errstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            fdst = open(dst, 'wb')
 | 
					            fdst = open(dst, 'wb')
 | 
				
			||||||
        except os.error, (errno, errstr):
 | 
					        except os.error as e:
 | 
				
			||||||
 | 
					            (errno, errstr) = e
 | 
				
			||||||
            raise DistutilsFileError, \
 | 
					            raise DistutilsFileError, \
 | 
				
			||||||
                  "could not create '%s': %s" % (dst, errstr)
 | 
					                  "could not create '%s': %s" % (dst, errstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while 1:
 | 
					        while 1:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                buf = fsrc.read(buffer_size)
 | 
					                buf = fsrc.read(buffer_size)
 | 
				
			||||||
            except os.error, (errno, errstr):
 | 
					            except os.error as e:
 | 
				
			||||||
 | 
					                (errno, errstr) = e
 | 
				
			||||||
                raise DistutilsFileError, \
 | 
					                raise DistutilsFileError, \
 | 
				
			||||||
                      "could not read from '%s': %s" % (src, errstr)
 | 
					                      "could not read from '%s': %s" % (src, errstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +65,8 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                fdst.write(buf)
 | 
					                fdst.write(buf)
 | 
				
			||||||
            except os.error, (errno, errstr):
 | 
					            except os.error as e:
 | 
				
			||||||
 | 
					                (errno, errstr) = e
 | 
				
			||||||
                raise DistutilsFileError, \
 | 
					                raise DistutilsFileError, \
 | 
				
			||||||
                      "could not write to '%s': %s" % (dst, errstr)
 | 
					                      "could not write to '%s': %s" % (dst, errstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -146,7 +151,7 @@ def copy_file (src, dst,
 | 
				
			||||||
        import macostools
 | 
					        import macostools
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            macostools.copy(src, dst, 0, preserve_times)
 | 
					            macostools.copy(src, dst, 0, preserve_times)
 | 
				
			||||||
        except os.error, exc:
 | 
					        except os.error as exc:
 | 
				
			||||||
            raise DistutilsFileError, \
 | 
					            raise DistutilsFileError, \
 | 
				
			||||||
                  "could not copy '%s' to '%s': %s" % (src, dst, exc[-1])
 | 
					                  "could not copy '%s' to '%s': %s" % (src, dst, exc[-1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -217,7 +222,8 @@ def move_file (src, dst,
 | 
				
			||||||
    copy_it = 0
 | 
					    copy_it = 0
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        os.rename(src, dst)
 | 
					        os.rename(src, dst)
 | 
				
			||||||
    except os.error, (num, msg):
 | 
					    except os.error as e:
 | 
				
			||||||
 | 
					        (num, msg) = e
 | 
				
			||||||
        if num == errno.EXDEV:
 | 
					        if num == errno.EXDEV:
 | 
				
			||||||
            copy_it = 1
 | 
					            copy_it = 1
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -228,7 +234,8 @@ def move_file (src, dst,
 | 
				
			||||||
        copy_file(src, dst)
 | 
					        copy_file(src, dst)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            os.unlink(src)
 | 
					            os.unlink(src)
 | 
				
			||||||
        except os.error, (num, msg):
 | 
					        except os.error as e:
 | 
				
			||||||
 | 
					            (num, msg) = e
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                os.unlink(dst)
 | 
					                os.unlink(dst)
 | 
				
			||||||
            except os.error:
 | 
					            except os.error:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -129,7 +129,7 @@ def load_macros(self, version):
 | 
				
			||||||
                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
 | 
					                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
 | 
					                self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
 | 
				
			||||||
        except KeyError, exc: #
 | 
					        except KeyError as exc: #
 | 
				
			||||||
            raise DistutilsPlatformError, \
 | 
					            raise DistutilsPlatformError, \
 | 
				
			||||||
                  ("""Python was built with Visual Studio 2003;
 | 
					                  ("""Python was built with Visual Studio 2003;
 | 
				
			||||||
extensions must be built with a compiler than can generate compatible binaries.
 | 
					extensions must be built with a compiler than can generate compatible binaries.
 | 
				
			||||||
| 
						 | 
					@ -371,7 +371,7 @@ def compile(self, sources,
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    self.spawn ([self.rc] + pp_opts +
 | 
					                    self.spawn ([self.rc] + pp_opts +
 | 
				
			||||||
                                [output_opt] + [input_opt])
 | 
					                                [output_opt] + [input_opt])
 | 
				
			||||||
                except DistutilsExecError, msg:
 | 
					                except DistutilsExecError as msg:
 | 
				
			||||||
                    raise CompileError, msg
 | 
					                    raise CompileError, msg
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            elif ext in self._mc_extensions:
 | 
					            elif ext in self._mc_extensions:
 | 
				
			||||||
| 
						 | 
					@ -400,7 +400,7 @@ def compile(self, sources,
 | 
				
			||||||
                    self.spawn ([self.rc] +
 | 
					                    self.spawn ([self.rc] +
 | 
				
			||||||
                                ["/fo" + obj] + [rc_file])
 | 
					                                ["/fo" + obj] + [rc_file])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                except DistutilsExecError, msg:
 | 
					                except DistutilsExecError as msg:
 | 
				
			||||||
                    raise CompileError, msg
 | 
					                    raise CompileError, msg
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					@ -414,7 +414,7 @@ def compile(self, sources,
 | 
				
			||||||
                self.spawn ([self.cc] + compile_opts + pp_opts +
 | 
					                self.spawn ([self.cc] + compile_opts + pp_opts +
 | 
				
			||||||
                            [input_opt, output_opt] +
 | 
					                            [input_opt, output_opt] +
 | 
				
			||||||
                            extra_postargs)
 | 
					                            extra_postargs)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return objects
 | 
					        return objects
 | 
				
			||||||
| 
						 | 
					@ -440,7 +440,7 @@ def create_static_lib (self,
 | 
				
			||||||
                pass                    # XXX what goes here?
 | 
					                pass                    # XXX what goes here?
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn ([self.lib] + lib_args)
 | 
					                self.spawn ([self.lib] + lib_args)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise LibError, msg
 | 
					                raise LibError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -519,7 +519,7 @@ def link (self,
 | 
				
			||||||
            self.mkpath (os.path.dirname (output_filename))
 | 
					            self.mkpath (os.path.dirname (output_filename))
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn ([self.linker] + ld_args)
 | 
					                self.spawn ([self.linker] + ld_args)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise LinkError, msg
 | 
					                raise LinkError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +78,7 @@ def _spawn_nt (cmd,
 | 
				
			||||||
        # spawn for NT requires a full path to the .exe
 | 
					        # spawn for NT requires a full path to the .exe
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            rc = os.spawnv(os.P_WAIT, executable, cmd)
 | 
					            rc = os.spawnv(os.P_WAIT, executable, cmd)
 | 
				
			||||||
        except OSError, exc:
 | 
					        except OSError as exc:
 | 
				
			||||||
            # this seems to happen when the command isn't found
 | 
					            # this seems to happen when the command isn't found
 | 
				
			||||||
            raise DistutilsExecError, \
 | 
					            raise DistutilsExecError, \
 | 
				
			||||||
                  "command '%s' failed: %s" % (cmd[0], exc[-1])
 | 
					                  "command '%s' failed: %s" % (cmd[0], exc[-1])
 | 
				
			||||||
| 
						 | 
					@ -103,7 +103,7 @@ def _spawn_os2 (cmd,
 | 
				
			||||||
        # spawnv for OS/2 EMX requires a full path to the .exe
 | 
					        # spawnv for OS/2 EMX requires a full path to the .exe
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            rc = os.spawnv(os.P_WAIT, executable, cmd)
 | 
					            rc = os.spawnv(os.P_WAIT, executable, cmd)
 | 
				
			||||||
        except OSError, exc:
 | 
					        except OSError as exc:
 | 
				
			||||||
            # this seems to happen when the command isn't found
 | 
					            # this seems to happen when the command isn't found
 | 
				
			||||||
            raise DistutilsExecError, \
 | 
					            raise DistutilsExecError, \
 | 
				
			||||||
                  "command '%s' failed: %s" % (cmd[0], exc[-1])
 | 
					                  "command '%s' failed: %s" % (cmd[0], exc[-1])
 | 
				
			||||||
| 
						 | 
					@ -131,7 +131,7 @@ def _spawn_posix (cmd,
 | 
				
			||||||
            #print "cmd[0] =", cmd[0]
 | 
					            #print "cmd[0] =", cmd[0]
 | 
				
			||||||
            #print "cmd =", cmd
 | 
					            #print "cmd =", cmd
 | 
				
			||||||
            exec_fn(cmd[0], cmd)
 | 
					            exec_fn(cmd[0], cmd)
 | 
				
			||||||
        except OSError, e:
 | 
					        except OSError as e:
 | 
				
			||||||
            sys.stderr.write("unable to execute %s: %s\n" %
 | 
					            sys.stderr.write("unable to execute %s: %s\n" %
 | 
				
			||||||
                             (cmd[0], e.strerror))
 | 
					                             (cmd[0], e.strerror))
 | 
				
			||||||
            os._exit(1)
 | 
					            os._exit(1)
 | 
				
			||||||
| 
						 | 
					@ -146,7 +146,7 @@ def _spawn_posix (cmd,
 | 
				
			||||||
        while 1:
 | 
					        while 1:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                (pid, status) = os.waitpid(pid, 0)
 | 
					                (pid, status) = os.waitpid(pid, 0)
 | 
				
			||||||
            except OSError, exc:
 | 
					            except OSError as exc:
 | 
				
			||||||
                import errno
 | 
					                import errno
 | 
				
			||||||
                if exc.errno == errno.EINTR:
 | 
					                if exc.errno == errno.EINTR:
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -344,7 +344,7 @@ def _init_posix():
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        filename = get_makefile_filename()
 | 
					        filename = get_makefile_filename()
 | 
				
			||||||
        parse_makefile(filename, g)
 | 
					        parse_makefile(filename, g)
 | 
				
			||||||
    except IOError, msg:
 | 
					    except IOError as msg:
 | 
				
			||||||
        my_msg = "invalid Python installation: unable to open %s" % filename
 | 
					        my_msg = "invalid Python installation: unable to open %s" % filename
 | 
				
			||||||
        if hasattr(msg, "strerror"):
 | 
					        if hasattr(msg, "strerror"):
 | 
				
			||||||
            my_msg = my_msg + " (%s)" % msg.strerror
 | 
					            my_msg = my_msg + " (%s)" % msg.strerror
 | 
				
			||||||
| 
						 | 
					@ -355,7 +355,7 @@ def _init_posix():
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        filename = get_config_h_filename()
 | 
					        filename = get_config_h_filename()
 | 
				
			||||||
        parse_config_h(open(filename), g)
 | 
					        parse_config_h(open(filename), g)
 | 
				
			||||||
    except IOError, msg:
 | 
					    except IOError as msg:
 | 
				
			||||||
        my_msg = "invalid Python installation: unable to open %s" % filename
 | 
					        my_msg = "invalid Python installation: unable to open %s" % filename
 | 
				
			||||||
        if hasattr(msg, "strerror"):
 | 
					        if hasattr(msg, "strerror"):
 | 
				
			||||||
            my_msg = my_msg + " (%s)" % msg.strerror
 | 
					            my_msg = my_msg + " (%s)" % msg.strerror
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -162,7 +162,7 @@ def preprocess(self, source,
 | 
				
			||||||
                self.mkpath(os.path.dirname(output_file))
 | 
					                self.mkpath(os.path.dirname(output_file))
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.spawn(pp_args)
 | 
					                self.spawn(pp_args)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise CompileError, msg
 | 
					                raise CompileError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
 | 
					    def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
 | 
				
			||||||
| 
						 | 
					@ -172,7 +172,7 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.spawn(compiler_so + cc_args + [src, '-o', obj] +
 | 
					            self.spawn(compiler_so + cc_args + [src, '-o', obj] +
 | 
				
			||||||
                       extra_postargs)
 | 
					                       extra_postargs)
 | 
				
			||||||
        except DistutilsExecError, msg:
 | 
					        except DistutilsExecError as msg:
 | 
				
			||||||
            raise CompileError, msg
 | 
					            raise CompileError, msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def create_static_lib(self, objects, output_libname,
 | 
					    def create_static_lib(self, objects, output_libname,
 | 
				
			||||||
| 
						 | 
					@ -196,7 +196,7 @@ def create_static_lib(self, objects, output_libname,
 | 
				
			||||||
            if self.ranlib:
 | 
					            if self.ranlib:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    self.spawn(self.ranlib + [output_filename])
 | 
					                    self.spawn(self.ranlib + [output_filename])
 | 
				
			||||||
                except DistutilsExecError, msg:
 | 
					                except DistutilsExecError as msg:
 | 
				
			||||||
                    raise LibError, msg
 | 
					                    raise LibError, msg
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            log.debug("skipping %s (up-to-date)", output_filename)
 | 
					            log.debug("skipping %s (up-to-date)", output_filename)
 | 
				
			||||||
| 
						 | 
					@ -250,7 +250,7 @@ def link(self, target_desc, objects,
 | 
				
			||||||
                    linker = _darwin_compiler_fixup(linker, ld_args)
 | 
					                    linker = _darwin_compiler_fixup(linker, ld_args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                self.spawn(linker + ld_args)
 | 
					                self.spawn(linker + ld_args)
 | 
				
			||||||
            except DistutilsExecError, msg:
 | 
					            except DistutilsExecError as msg:
 | 
				
			||||||
                raise LinkError, msg
 | 
					                raise LinkError, msg
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            log.debug("skipping %s (up-to-date)", output_filename)
 | 
					            log.debug("skipping %s (up-to-date)", output_filename)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,7 +229,7 @@ def _subst (match, local_vars=local_vars):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
 | 
					        return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
 | 
				
			||||||
    except KeyError, var:
 | 
					    except KeyError as var:
 | 
				
			||||||
        raise ValueError, "invalid variable '$%s'" % var
 | 
					        raise ValueError, "invalid variable '$%s'" % var
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# subst_vars ()
 | 
					# subst_vars ()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1604,8 +1604,8 @@ class DebugRunner(DocTestRunner):
 | 
				
			||||||
         ...                                    {}, 'foo', 'foo.py', 0)
 | 
					         ...                                    {}, 'foo', 'foo.py', 0)
 | 
				
			||||||
         >>> try:
 | 
					         >>> try:
 | 
				
			||||||
         ...     runner.run(test)
 | 
					         ...     runner.run(test)
 | 
				
			||||||
         ... except UnexpectedException, failure:
 | 
					         ... except UnexpectedException as f:
 | 
				
			||||||
         ...     pass
 | 
					         ...     failure = f
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         >>> failure.test is test
 | 
					         >>> failure.test is test
 | 
				
			||||||
         True
 | 
					         True
 | 
				
			||||||
| 
						 | 
					@ -1632,8 +1632,8 @@ class DebugRunner(DocTestRunner):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         >>> try:
 | 
					         >>> try:
 | 
				
			||||||
         ...    runner.run(test)
 | 
					         ...    runner.run(test)
 | 
				
			||||||
         ... except DocTestFailure, failure:
 | 
					         ... except DocTestFailure as f:
 | 
				
			||||||
         ...    pass
 | 
					         ...    failure = f
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       DocTestFailure objects provide access to the test:
 | 
					       DocTestFailure objects provide access to the test:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2141,8 +2141,8 @@ def debug(self):
 | 
				
			||||||
             >>> case = DocTestCase(test)
 | 
					             >>> case = DocTestCase(test)
 | 
				
			||||||
             >>> try:
 | 
					             >>> try:
 | 
				
			||||||
             ...     case.debug()
 | 
					             ...     case.debug()
 | 
				
			||||||
             ... except UnexpectedException, failure:
 | 
					             ... except UnexpectedException as f:
 | 
				
			||||||
             ...     pass
 | 
					             ...     failure = f
 | 
				
			||||||
 | 
					
 | 
				
			||||||
           The UnexpectedException contains the test, the example, and
 | 
					           The UnexpectedException contains the test, the example, and
 | 
				
			||||||
           the original exception:
 | 
					           the original exception:
 | 
				
			||||||
| 
						 | 
					@ -2170,8 +2170,8 @@ def debug(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
             >>> try:
 | 
					             >>> try:
 | 
				
			||||||
             ...    case.debug()
 | 
					             ...    case.debug()
 | 
				
			||||||
             ... except DocTestFailure, failure:
 | 
					             ... except DocTestFailure as f:
 | 
				
			||||||
             ...    pass
 | 
					             ...    failure = f
 | 
				
			||||||
 | 
					
 | 
				
			||||||
           DocTestFailure objects provide access to the test:
 | 
					           DocTestFailure objects provide access to the test:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,7 +81,7 @@ def uu_decode(input,errors='strict'):
 | 
				
			||||||
            break
 | 
					            break
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            data = a2b_uu(s)
 | 
					            data = a2b_uu(s)
 | 
				
			||||||
        except binascii.Error, v:
 | 
					        except binascii.Error as v:
 | 
				
			||||||
            # Workaround for broken uuencoders by /Fredrik Lundh
 | 
					            # Workaround for broken uuencoders by /Fredrik Lundh
 | 
				
			||||||
            nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3
 | 
					            nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3
 | 
				
			||||||
            data = a2b_uu(s[:nbytes])
 | 
					            data = a2b_uu(s[:nbytes])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -148,12 +148,12 @@ def phase2(self): # Distinguish files, directories, funnies
 | 
				
			||||||
            ok = 1
 | 
					            ok = 1
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                a_stat = os.stat(a_path)
 | 
					                a_stat = os.stat(a_path)
 | 
				
			||||||
            except os.error, why:
 | 
					            except os.error as why:
 | 
				
			||||||
                # print 'Can\'t stat', a_path, ':', why[1]
 | 
					                # print 'Can\'t stat', a_path, ':', why[1]
 | 
				
			||||||
                ok = 0
 | 
					                ok = 0
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                b_stat = os.stat(b_path)
 | 
					                b_stat = os.stat(b_path)
 | 
				
			||||||
            except os.error, why:
 | 
					            except os.error as why:
 | 
				
			||||||
                # print 'Can\'t stat', b_path, ':', why[1]
 | 
					                # print 'Can\'t stat', b_path, ':', why[1]
 | 
				
			||||||
                ok = 0
 | 
					                ok = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -119,7 +119,7 @@ def connect(self, host = '', port = 0):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                self.sock = socket.socket(af, socktype, proto)
 | 
					                self.sock = socket.socket(af, socktype, proto)
 | 
				
			||||||
                self.sock.connect(sa)
 | 
					                self.sock.connect(sa)
 | 
				
			||||||
            except socket.error, msg:
 | 
					            except socket.error as msg:
 | 
				
			||||||
                if self.sock:
 | 
					                if self.sock:
 | 
				
			||||||
                    self.sock.close()
 | 
					                    self.sock.close()
 | 
				
			||||||
                self.sock = None
 | 
					                self.sock = None
 | 
				
			||||||
| 
						 | 
					@ -277,7 +277,7 @@ def makeport(self):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                sock = socket.socket(af, socktype, proto)
 | 
					                sock = socket.socket(af, socktype, proto)
 | 
				
			||||||
                sock.bind(sa)
 | 
					                sock.bind(sa)
 | 
				
			||||||
            except socket.error, msg:
 | 
					            except socket.error as msg:
 | 
				
			||||||
                if sock:
 | 
					                if sock:
 | 
				
			||||||
                    sock.close()
 | 
					                    sock.close()
 | 
				
			||||||
                sock = None
 | 
					                sock = None
 | 
				
			||||||
| 
						 | 
					@ -496,7 +496,7 @@ def cwd(self, dirname):
 | 
				
			||||||
        if dirname == '..':
 | 
					        if dirname == '..':
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                return self.voidcmd('CDUP')
 | 
					                return self.voidcmd('CDUP')
 | 
				
			||||||
            except error_perm, msg:
 | 
					            except error_perm as msg:
 | 
				
			||||||
                if msg.args[0][:3] != '500':
 | 
					                if msg.args[0][:3] != '500':
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
        elif dirname == '':
 | 
					        elif dirname == '':
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ def main(logfile):
 | 
				
			||||||
    stats.sort_stats('time', 'calls')
 | 
					    stats.sort_stats('time', 'calls')
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        stats.print_stats(20)
 | 
					        stats.print_stats(20)
 | 
				
			||||||
    except IOError, e:
 | 
					    except IOError as e:
 | 
				
			||||||
        if e.errno != errno.EPIPE:
 | 
					        if e.errno != errno.EPIPE:
 | 
				
			||||||
            raise
 | 
					            raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -463,7 +463,7 @@ def test(args = None):
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            f = open(file, 'r')
 | 
					            f = open(file, 'r')
 | 
				
			||||||
        except IOError, msg:
 | 
					        except IOError as msg:
 | 
				
			||||||
            print file, ":", msg
 | 
					            print file, ":", msg
 | 
				
			||||||
            sys.exit(1)
 | 
					            sys.exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -667,7 +667,7 @@ def connect(self):
 | 
				
			||||||
                if self.debuglevel > 0:
 | 
					                if self.debuglevel > 0:
 | 
				
			||||||
                    print "connect: (%s, %s)" % (self.host, self.port)
 | 
					                    print "connect: (%s, %s)" % (self.host, self.port)
 | 
				
			||||||
                self.sock.connect(sa)
 | 
					                self.sock.connect(sa)
 | 
				
			||||||
            except socket.error, msg:
 | 
					            except socket.error as msg:
 | 
				
			||||||
                if self.debuglevel > 0:
 | 
					                if self.debuglevel > 0:
 | 
				
			||||||
                    print 'connect fail:', (self.host, self.port)
 | 
					                    print 'connect fail:', (self.host, self.port)
 | 
				
			||||||
                if self.sock:
 | 
					                if self.sock:
 | 
				
			||||||
| 
						 | 
					@ -713,7 +713,7 @@ def send(self, str):
 | 
				
			||||||
                    data=str.read(blocksize)
 | 
					                    data=str.read(blocksize)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.sock.sendall(str)
 | 
					                self.sock.sendall(str)
 | 
				
			||||||
        except socket.error, v:
 | 
					        except socket.error as v:
 | 
				
			||||||
            if v[0] == 32:      # Broken pipe
 | 
					            if v[0] == 32:      # Broken pipe
 | 
				
			||||||
                self.close()
 | 
					                self.close()
 | 
				
			||||||
            raise
 | 
					            raise
 | 
				
			||||||
| 
						 | 
					@ -868,7 +868,7 @@ def request(self, method, url, body=None, headers={}):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self._send_request(method, url, body, headers)
 | 
					            self._send_request(method, url, body, headers)
 | 
				
			||||||
        except socket.error, v:
 | 
					        except socket.error as v:
 | 
				
			||||||
            # trap 'Broken pipe' if we're allowed to automatically reconnect
 | 
					            # trap 'Broken pipe' if we're allowed to automatically reconnect
 | 
				
			||||||
            if v[0] != 32 or not self.auto_open:
 | 
					            if v[0] != 32 or not self.auto_open:
 | 
				
			||||||
                raise
 | 
					                raise
 | 
				
			||||||
| 
						 | 
					@ -890,7 +890,7 @@ def _send_request(self, method, url, body, headers):
 | 
				
			||||||
            thelen=None
 | 
					            thelen=None
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                thelen=str(len(body))
 | 
					                thelen=str(len(body))
 | 
				
			||||||
            except TypeError, te:
 | 
					            except TypeError as te:
 | 
				
			||||||
                # If this is a file-like object, try to
 | 
					                # If this is a file-like object, try to
 | 
				
			||||||
                # fstat its file descriptor
 | 
					                # fstat its file descriptor
 | 
				
			||||||
                import os
 | 
					                import os
 | 
				
			||||||
| 
						 | 
					@ -1019,7 +1019,7 @@ def _read(self):
 | 
				
			||||||
        while True:
 | 
					        while True:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                buf = self._ssl.read(self._bufsize)
 | 
					                buf = self._ssl.read(self._bufsize)
 | 
				
			||||||
            except socket.sslerror, err:
 | 
					            except socket.sslerror as err:
 | 
				
			||||||
                if (err[0] == socket.SSL_ERROR_WANT_READ
 | 
					                if (err[0] == socket.SSL_ERROR_WANT_READ
 | 
				
			||||||
                    or err[0] == socket.SSL_ERROR_WANT_WRITE):
 | 
					                    or err[0] == socket.SSL_ERROR_WANT_WRITE):
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
| 
						 | 
					@ -1027,7 +1027,7 @@ def _read(self):
 | 
				
			||||||
                    or err[0] == socket.SSL_ERROR_EOF):
 | 
					                    or err[0] == socket.SSL_ERROR_EOF):
 | 
				
			||||||
                    break
 | 
					                    break
 | 
				
			||||||
                raise
 | 
					                raise
 | 
				
			||||||
            except socket.error, err:
 | 
					            except socket.error as err:
 | 
				
			||||||
                if err[0] == errno.EINTR:
 | 
					                if err[0] == errno.EINTR:
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
                if err[0] == errno.EBADF:
 | 
					                if err[0] == errno.EBADF:
 | 
				
			||||||
| 
						 | 
					@ -1215,7 +1215,7 @@ def getreply(self):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            response = self._conn.getresponse()
 | 
					            response = self._conn.getresponse()
 | 
				
			||||||
        except BadStatusLine, e:
 | 
					        except BadStatusLine as e:
 | 
				
			||||||
            ### hmm. if getresponse() ever closes the socket on a bad request,
 | 
					            ### hmm. if getresponse() ever closes the socket on a bad request,
 | 
				
			||||||
            ### then we are going to have problems with self.sock
 | 
					            ### then we are going to have problems with self.sock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,7 +94,7 @@ def listclasses(self):
 | 
				
			||||||
            return []
 | 
					            return []
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            dict = pyclbr.readmodule_ex(name, [dir] + sys.path)
 | 
					            dict = pyclbr.readmodule_ex(name, [dir] + sys.path)
 | 
				
			||||||
        except ImportError, msg:
 | 
					        except ImportError as msg:
 | 
				
			||||||
            return []
 | 
					            return []
 | 
				
			||||||
        items = []
 | 
					        items = []
 | 
				
			||||||
        self.classes = {}
 | 
					        self.classes = {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -505,7 +505,7 @@ def open_module(self, event=None):
 | 
				
			||||||
        # XXX Ought to insert current file's directory in front of path
 | 
					        # XXX Ought to insert current file's directory in front of path
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            (f, file, (suffix, mode, type)) = _find_module(name)
 | 
					            (f, file, (suffix, mode, type)) = _find_module(name)
 | 
				
			||||||
        except (NameError, ImportError), msg:
 | 
					        except (NameError, ImportError) as msg:
 | 
				
			||||||
            tkMessageBox.showerror("Import error", str(msg), parent=self.text)
 | 
					            tkMessageBox.showerror("Import error", str(msg), parent=self.text)
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        if type != imp.PY_SOURCE:
 | 
					        if type != imp.PY_SOURCE:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue