Update syntax of 'except' statements for compatibility with Python 3.
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 20 Sep 2009 10:57:44 +0000 (10:57 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 20 Sep 2009 10:57:44 +0000 (10:57 -0000)
(2to3-3.1 -f except -nw ${FILES})

svn path=/main/trunk/; revision=14289

67 files changed:
bin/archive-conf
bin/clean_locks
bin/dispatch-conf
bin/ebuild
bin/egencache
bin/emaint
bin/emerge
bin/env-update
bin/fixpackages
bin/glsa-check
bin/portageq
bin/quickpkg
bin/regenworld
bin/repoman
pym/_emerge/BinpkgVerifier.py
pym/_emerge/BlockerCache.py
pym/_emerge/EbuildBuildDir.py
pym/_emerge/EbuildFetchonly.py
pym/_emerge/MetadataRegen.py
pym/_emerge/Package.py
pym/_emerge/PackageUninstall.py
pym/_emerge/PollScheduler.py
pym/_emerge/Scheduler.py
pym/_emerge/SpawnProcess.py
pym/_emerge/SubProcess.py
pym/_emerge/actions.py
pym/_emerge/changelog.py
pym/_emerge/depgraph.py
pym/_emerge/emergelog.py
pym/_emerge/main.py
pym/_emerge/search.py
pym/_emerge/unmerge.py
pym/portage/__init__.py
pym/portage/cache/anydbm.py
pym/portage/cache/ebuild_xattr.py
pym/portage/cache/flat_hash.py
pym/portage/cache/flat_list.py
pym/portage/cache/metadata.py
pym/portage/cache/sql_template.py
pym/portage/cache/sqlite.py
pym/portage/cache/template.py
pym/portage/cache/util.py
pym/portage/checksum.py
pym/portage/cvstree.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/dispatch_conf.py
pym/portage/eclass_cache.py
pym/portage/elog/__init__.py
pym/portage/elog/mod_mail.py
pym/portage/elog/mod_mail_summary.py
pym/portage/env/loaders.py
pym/portage/getbinpkg.py
pym/portage/locks.py
pym/portage/mail.py
pym/portage/manifest.py
pym/portage/output.py
pym/portage/process.py
pym/portage/sets/__init__.py
pym/portage/sets/dbapi.py
pym/portage/sets/files.py
pym/portage/tests/ebuild/test_spawn.py
pym/portage/update.py
pym/portage/util.py
pym/portage/xpak.py
pym/repoman/utilities.py

index f9a4d5724c5df61a016b72165cc6bd997fde6b4b..680a99cb50a9baf9f444696f768b908c42160db5 100755 (executable)
@@ -72,7 +72,7 @@ def archive_conf():
             file = file.rstrip()
             try:
                 contents = open(file, "r")
-            except IOError, e:
+            except IOError as e:
                 print >> sys.stderr, 'archive-conf: Unable to open %s: %s' % (file, e)
                 sys.exit(1)
             lines = contents.readlines()
index 9799ad9997c39a4585a07e0a29f8e71f5d86f9b6..ec593a3116406b73b77ca6dfbbd22393f60c3655 100755 (executable)
@@ -38,7 +38,7 @@ for x in sys.argv[1:]:
                        print y
                print
                
-       except OSError, e:
+       except OSError as e:
                if e.errno in (errno.ENOENT, errno.ENOTDIR):
                        print "!!! %s is not a directory or does not exist" % x
                else:
index 68fd3e899f49c720151c788f5470c88b6d5d0d4c..d0309701e3c1e419dc59ad8d512e41a0020ba60b 100755 (executable)
@@ -51,7 +51,7 @@ while SCRATCH_DIR is None:
             continue
         os.mkdir(mydir)
         SCRATCH_DIR = mydir
-    except OSError, e:
+    except OSError as e:
         if e.errno != 17:
             raise
 os.umask(oldmask)
@@ -305,7 +305,7 @@ class dispatch:
         os.system((DIFF_CONTENTS % (curconf, newconf)) + '>>' + self.options["log-file"])
         try:
             os.rename(newconf, curconf)
-        except (IOError, os.error), why:
+        except (IOError, os.error) as why:
             print >> sys.stderr, 'dispatch-conf: Error renaming %s to %s: %s; fatal' % \
                   (newconf, curconf, str(why))
 
index 18abb00e862222d177c5d940caeb3d96acf572b9..e41764b8ed718e66637a853e8bc330aeeeff348f 100755 (executable)
@@ -255,17 +255,17 @@ for arg in pargs:
        except KeyError:
                # aux_get error
                a = 1
-       except UnsupportedAPIException, e:
+       except UnsupportedAPIException as e:
                from textwrap import wrap
                msg = wrap(str(e), 70)
                del e
                for x in msg:
                        portage.writemsg("!!! %s\n" % x, noiselevel=-1)
                a = 1
-       except PortagePackageException, e:
+       except PortagePackageException as e:
                portage.writemsg("!!! %s\n" % (e,), noiselevel=-1)
                a = 1
-       except PermissionDenied, e:
+       except PermissionDenied as e:
                portage.writemsg("!!! Permission Denied: %s\n" % (e,), noiselevel=-1)
                a = 1
        if a == None:
index 2b3af4e5080150ea321ab05e46705621bd0a5ae9..6c46896c04ca1ad04e72c455d295574b8c645702 100755 (executable)
@@ -157,7 +157,7 @@ class GenCache(object):
                        try:
                                try:
                                        self._trg_cache[cpv] = metadata
-                               except StatCollision, sc:
+                               except StatCollision as sc:
                                        # If the content of a cache entry changes and neither the
                                        # file mtime nor size changes, it will prevent rsync from
                                        # detecting changes. Cache backends may raise this
@@ -174,7 +174,7 @@ class GenCache(object):
                                        max_mtime = long(max_mtime)
                                        try:
                                                os.utime(ebuild_path, (max_mtime, max_mtime))
-                                       except OSError, e:
+                                       except OSError as e:
                                                self.returncode |= 1
                                                writemsg_level(
                                                        "%s writing target: %s\n" % (cpv, e),
@@ -184,7 +184,7 @@ class GenCache(object):
                                                self._trg_cache[cpv] = metadata
                                                self._portdb.auxdb[repo_path][cpv] = metadata
 
-                       except CacheError, ce:
+                       except CacheError as ce:
                                self.returncode |= 1
                                writemsg_level(
                                        "%s writing target: %s\n" % (cpv, ce),
@@ -208,7 +208,7 @@ class GenCache(object):
                                                        level=logging.ERROR, noiselevel=-1)
                                        else:
                                                dead_nodes.add(cpv)
-                       except CacheError, ce:
+                       except CacheError as ce:
                                self.returncode |= 1
                                writemsg_level(
                                        "Error listing cache entries for " + \
@@ -230,7 +230,7 @@ class GenCache(object):
                                                cp_missing.discard(cp)
                                                if cp in cp_set:
                                                        dead_nodes.add(cpv)
-                       except CacheError, ce:
+                       except CacheError as ce:
                                self.returncode |= 1
                                writemsg_level(
                                        "Error listing cache entries for " + \
@@ -252,7 +252,7 @@ class GenCache(object):
                                        del trg_cache[k]
                                except KeyError:
                                        pass
-                               except CacheError, ce:
+                               except CacheError as ce:
                                        self.returncode |= 1
                                        writemsg_level(
                                                "%s deleting stale cache: %s\n" % (k, ce),
@@ -261,7 +261,7 @@ class GenCache(object):
                if not trg_cache.autocommits:
                        try:
                                trg_cache.commit()
-                       except CacheError, ce:
+                       except CacheError as ce:
                                self.returncode |= 1
                                writemsg_level(
                                        "committing target: %s\n" % (ce,),
index 6652b6ed54860ead1a606ccec4f608772ebc8073..ac791c14c076f6c35dc7ed43d74e1cd73a0bef7d 100755 (executable)
@@ -383,7 +383,7 @@ class VdbKeyHandler(object):
                                                                keyfile = open(mydir+os.sep+k, "w")
                                                                keyfile.write(s+"\n")
                                                                keyfile.close()
-                                                       except (IOError, OSError), e:
+                                                       except (IOError, OSError) as e:
                                                                errors.append("Could not write %s, reason was: %s" % (mydir+k, e))
                
                return errors
index 03cf171cd530feb74d95f17e263240adf7d0c14a..fca852d0269527324048467179f1e81892116e09 100755 (executable)
@@ -38,10 +38,10 @@ if __name__ == "__main__":
        from portage.exception import ParseError, PermissionDenied
        try:
                retval = emerge_main()
-       except PermissionDenied, e:
+       except PermissionDenied as e:
                sys.stderr.write("Permission denied: '%s'\n" % str(e))
                sys.exit(e.errno)
-       except ParseError, e:
+       except ParseError as e:
                sys.stderr.write("%s\n" % str(e))
                sys.exit(1)
        except SystemExit:
index 30e25d0b2a1c4b68a2928d3197a78a853bc8ebab..3fa21c7fa2c35292e75ae805d8148e218ec5c192 100755 (executable)
@@ -31,7 +31,7 @@ except ImportError:
        import portage
 try:
        portage.env_update(makelinks)
-except IOError, e:
+except IOError as e:
        if e.errno == errno.EACCES:
                print "env-update: Need superuser access"
                sys.exit(1)
index a5f24a7e58f68cbc09e2eec6ac72d3596959d938..dc7a5d24f979121bc2a879624c8f3a7feb3176a1 100755 (executable)
@@ -19,7 +19,7 @@ mtimedb = portage.mtimedb
 
 try:
        os.nice(int(mysettings.get("PORTAGE_NICENESS", "0")))
-except (OSError, ValueError), e:
+except (OSError, ValueError) as e:
        portage.writemsg("!!! Failed to change nice value to '%s'\n" % \
                mysettings["PORTAGE_NICENESS"])
        portage.writemsg("!!! %s\n" % str(e))
index ad06136e2bfb6b4d9a6289b988ee5f6b07fb6a98..d1fdb207038615537515809563857cdfa22face7 100755 (executable)
@@ -124,7 +124,7 @@ if "affected" in params:
        for x in todolist:
                try:
                        myglsa = Glsa(x, portage.settings, vardb, portdb)
-               except (GlsaTypeException, GlsaFormatException), e:
+               except (GlsaTypeException, GlsaFormatException) as e:
                        if verbose:
                                sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (x, e)))
                        continue
@@ -149,7 +149,7 @@ def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr):
        for myid in myglsalist:
                try:
                        myglsa = Glsa(myid, portage.settings, vardb, portdb)
-               except (GlsaTypeException, GlsaFormatException), e:
+               except (GlsaTypeException, GlsaFormatException) as e:
                        if verbose:
                                fd2.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
                        continue
@@ -195,7 +195,7 @@ if mode in ["dump", "fix", "inject", "pretend"]:
        for myid in glsalist:
                try:
                        myglsa = Glsa(myid, portage.settings, vardb, portdb)
-               except (GlsaTypeException, GlsaFormatException), e:
+               except (GlsaTypeException, GlsaFormatException) as e:
                        if verbose:
                                sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
                        continue
@@ -247,7 +247,7 @@ if mode == "test":
        for myid in glsalist:
                try:
                        myglsa = Glsa(myid, portage.settings, vardb, portdb)
-               except (GlsaTypeException, GlsaFormatException), e:
+               except (GlsaTypeException, GlsaFormatException) as e:
                        if verbose:
                                sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
                        continue
@@ -296,7 +296,7 @@ if mode == "mail":
        for myid in glsalist:
                try:
                        myglsa = Glsa(myid, portage.settings, vardb, portdb)
-               except (GlsaTypeException, GlsaFormatException), e:
+               except (GlsaTypeException, GlsaFormatException) as e:
                        if verbose:
                                sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
                        continue
index 8cb7a2b132317a2571524927a82780e1f28bb990..04c0ca034d2bd5a2b172e5651c07b4f521b5c934 100755 (executable)
@@ -618,13 +618,13 @@ def main():
                retval = function(args)
                if retval:
                        sys.exit(retval)
-       except portage.exception.PermissionDenied, e:
+       except portage.exception.PermissionDenied as e:
                sys.stderr.write("Permission denied: '%s'\n" % str(e))
                sys.exit(e.errno)
-       except portage.exception.ParseError, e:
+       except portage.exception.ParseError as e:
                sys.stderr.write("%s\n" % str(e))
                sys.exit(1)
-       except ValueError, e:
+       except ValueError as e:
                if not e.args or \
                        not hasattr(e.args[0], "__len__") or \
                        len(e.args[0]) < 2:
index 53f7e9b272f8d24b06c29bfe972d2bb17a33d7bc..e0aaf63bde7bdbe34de4ec38eb8be9ede84c1bef 100755 (executable)
@@ -45,7 +45,7 @@ def quickpkg_main(options, args, eout):
        for arg in args:
                try:
                        atom = dep_expand(arg, mydb=vardb, settings=vartree.settings)
-               except ValueError, e:
+               except ValueError as e:
                        # Multiple matches thrown from cpv_expand
                        eout.eerror("Please use a more specific atom: %s" % \
                                " ".join(e.args[0]))
@@ -83,7 +83,7 @@ def quickpkg_main(options, args, eout):
                                try:
                                        restrict = flatten(use_reduce(
                                                paren_reduce(restrict), uselist=use))
-                               except InvalidDependString, e:
+                               except InvalidDependString as e:
                                        eout.eerror("Invalid RESTRICT metadata " + \
                                                "for '%s': %s; skipping" % (cpv, str(e)))
                                        del e
@@ -140,7 +140,7 @@ def quickpkg_main(options, args, eout):
                        binpkg_path = bintree.getname(cpv)
                        try:
                                s = os.stat(binpkg_path)
-                       except OSError, e:
+                       except OSError as e:
                                # Sanity check, shouldn't happen normally.
                                eout.eend(1)
                                eout.eerror(str(e))
index e8eb1253d39c880670f04e74bfe3906c37fe21bb..932995d5a26a1048a4d930475928efb0481e0d91 100755 (executable)
@@ -89,7 +89,7 @@ for mykey in biglist:
        except (portage.exception.InvalidAtom, KeyError):
                if "--debug" in sys.argv:
                        print "* ignoring broken log entry for %s (likely injected)" % mykey
-       except ValueError, e:
+       except ValueError as e:
                print "* %s is an ambigous package name, candidates are:\n%s" % (mykey, e)
                continue
        if mylist:
index 0537c31725cc0253c0860cc46fabde33c7b037aa..570c0b9364b5c12eae92bf9c154d21ee5431579a 100755 (executable)
@@ -778,7 +778,7 @@ else:
                else:
                        must_fetch=0
 
-       except (OSError,IOError), e:
+       except (OSError,IOError) as e:
                if e.errno != 2:
                        print red("!!!")+" caught exception '%s' for %s/metadata.dtd, bailing" % (str(e), portage.CACHE_PATH)
                        sys.exit(1)
@@ -791,16 +791,16 @@ else:
                try:
                        try:
                                os.unlink(metadata_dtd)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
                        val=portage.fetch(['http://www.gentoo.org/dtd/metadata.dtd'],repoman_settings,fetchonly=0, \
                                try_mirrors=0)
 
-               except SystemExit, e:
+               except SystemExit as e:
                        raise  # Need to propogate this
-               except Exception,e:
+               except Exception as e:
                        print
                        print red("!!!")+" attempting to fetch 'http://www.gentoo.org/dtd/metadata.dtd', caught"
                        print red("!!!")+" exception '%s' though." % str(e)
@@ -999,7 +999,7 @@ for x in scanlist:
                                encoding=_encodings['fs'], errors='strict'),
                                mode='r', encoding=_encodings['repo.content']):
                                line +=1
-               except UnicodeDecodeError, ue:
+               except UnicodeDecodeError as ue:
                        stats["file.UTF8"] += 1
                        s = ue.object[:ue.start]
                        l2 = s.count("\n")
@@ -1071,7 +1071,7 @@ for x in scanlist:
        for mykey in fetchlist_dict:
                try:
                        myfiles_all.extend(fetchlist_dict[mykey])
-               except portage.exception.InvalidDependString, e:
+               except portage.exception.InvalidDependString as e:
                        src_uri_error = True
                        try:
                                portdb.aux_get(mykey, ["SRC_URI"])
@@ -1107,7 +1107,7 @@ for x in scanlist:
                        full_path = os.path.join(repodir, relative_path)
                        try:
                                mystat = os.stat(full_path)
-                       except OSError, oe:
+                       except OSError as oe:
                                if oe.errno == 2:
                                        # don't worry about it.  it likely was removed via fix above.
                                        continue
@@ -1174,7 +1174,7 @@ for x in scanlist:
                        f = open(os.path.join(checkdir, "metadata.xml"))
                        utilities.parse_metadata_use(f, muselist)
                        f.close()
-               except (EnvironmentError, ParseError), e:
+               except (EnvironmentError, ParseError) as e:
                        metadata_bad = True
                        stats["metadata.bad"] += 1
                        fails["metadata.bad"].append("%s/metadata.xml: %s" % (x, e))
@@ -1416,14 +1416,14 @@ for x in scanlist:
                        except ValueError:
                                badsyntax.append("parenthesis mismatch")
                                mydeplist = []
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                badsyntax.append(str(e))
                                del e
                                mydeplist = []
 
                        try:
                                portage.dep.use_reduce(mydeplist, matchall=1)
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                badsyntax.append(str(e))
 
                        for token in operator_tokens:
@@ -1565,7 +1565,7 @@ for x in scanlist:
                try:
                        myrestrict = portage.dep.use_reduce(
                                portage.dep.paren_reduce(myaux["RESTRICT"]), matchall=1)
-               except portage.exception.InvalidDependString, e:
+               except portage.exception.InvalidDependString as e:
                        stats["RESTRICT.syntax"] = stats["RESTRICT.syntax"] + 1
                        fails["RESTRICT.syntax"].append(
                                "%s: RESTRICT: %s" % (relative_path, e))
@@ -1833,7 +1833,7 @@ else:
                try:
                        myvcstree=portage.cvstree.getentries("./",recursive=1)
                        myunadded=portage.cvstree.findunadded(myvcstree,recursive=1,basedir="./")
-               except SystemExit, e:
+               except SystemExit as e:
                        raise  # TODO propogate this
                except:
                        err("Error retrieving CVS tree; exiting.")
@@ -1841,7 +1841,7 @@ else:
                try:
                        svnstatus=os.popen("svn status --no-ignore").readlines()
                        myunadded = [ "./"+elem.rstrip().split()[1] for elem in svnstatus if elem.startswith("?") or elem.startswith("I") ]
-               except SystemExit, e:
+               except SystemExit as e:
                        raise  # TODO propogate this
                except:
                        err("Error retrieving SVN info; exiting.")
@@ -2005,7 +2005,7 @@ else:
                        commitmessage = f.read()
                        f.close()
                        del f
-               except (IOError, OSError), e:
+               except (IOError, OSError) as e:
                        if e.errno == errno.ENOENT:
                                portage.writemsg("!!! File Not Found: --commitmsgfile='%s'\n" % options.commitmsgfile)
                        else:
@@ -2252,7 +2252,7 @@ else:
                                        if not os.path.isdir(repoman_settings["O"]):
                                                continue
                                        gpgsign(os.path.join(repoman_settings["O"], "Manifest"))
-               except portage.exception.PortageException, e:
+               except portage.exception.PortageException as e:
                        portage.writemsg("!!! %s\n" % str(e))
                        portage.writemsg("!!! Disabled FEATURES='sign'\n")
                        signed = False
index 36e1bb8b640cbb19077a01d8bac605bad18946d8..404becf090b70917c880cd0dd89f71731cc4c310 100644 (file)
@@ -42,7 +42,7 @@ class BinpkgVerifier(AsynchronousTask):
                                writemsg("!!! Fetching Binary failed " + \
                                        "for '%s'\n" % pkg.cpv, noiselevel=-1)
                                rval = 1
-                       except portage.exception.DigestException, e:
+                       except portage.exception.DigestException as e:
                                writemsg("\n!!! Digest verification failed:\n",
                                        noiselevel=-1)
                                writemsg("!!! %s\n" % e.value[0],
index 2af47ca858200fc646d99e02c8fdad4cf6703ee7..db16fa83a5df426b4e0f65191296808eb2047b99 100644 (file)
@@ -55,7 +55,7 @@ class BlockerCache(portage.cache.mappings.MutableMapping):
                        self._cache_data = mypickle.load()
                        f.close()
                        del f
-               except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError), e:
+               except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e:
                        if isinstance(e, pickle.UnpicklingError):
                                writemsg("!!! Error loading '%s': %s\n" % \
                                        (self._cache_filename, str(e)), noiselevel=-1)
@@ -140,7 +140,7 @@ class BlockerCache(portage.cache.mappings.MutableMapping):
                                f.close()
                                portage.util.apply_secpass_permissions(
                                        self._cache_filename, gid=portage.portage_gid, mode=0644)
-                       except (IOError, OSError), e:
+                       except (IOError, OSError) as e:
                                pass
                        self._modified.clear()
 
index d9f8199667add4f8b0d2d92698ece67e6800f88c..d856d1912b5fb72eb3074e58823000ee71769d62 100644 (file)
@@ -83,7 +83,7 @@ class EbuildBuildDir(SlotObject):
                        if catdir_lock:
                                try:
                                        os.rmdir(catdir)
-                               except OSError, e:
+                               except OSError as e:
                                        if e.errno not in (errno.ENOENT,
                                                errno.ENOTEMPTY, errno.EEXIST):
                                                raise
index d65e2b2b12b94381ad051c6b8e1f9444c5376b27..256a06c6902d43f5379719e108ad0173496612b5 100644 (file)
@@ -44,7 +44,7 @@ class EbuildFetchonly(SlotObject):
                from tempfile import mkdtemp
                try:
                        private_tmpdir = mkdtemp("", "._portage_fetch_.", global_tmpdir)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != portage.exception.PermissionDenied.errno:
                                raise
                        raise portage.exception.PermissionDenied(global_tmpdir)
index ee6eb997af0f8edf865be8e85a62533dbba67444..4c237d34c035be22d2f107fd139deec2484e7edb 100644 (file)
@@ -90,7 +90,7 @@ class MetadataRegen(PollScheduler):
                        for mytree in portdb.porttrees:
                                try:
                                        dead_nodes[mytree] = set(portdb.auxdb[mytree].iterkeys())
-                               except CacheError, e:
+                               except CacheError as e:
                                        portage.writemsg("Error listing cache entries for " + \
                                                "'%s': %s, continuing...\n" % (mytree, e),
                                                noiselevel=-1)
@@ -105,7 +105,7 @@ class MetadataRegen(PollScheduler):
                                        dead_nodes[mytree] = set(cpv for cpv in \
                                                portdb.auxdb[mytree].iterkeys() \
                                                if cpv_getkey(cpv) in cp_set)
-                               except CacheError, e:
+                               except CacheError as e:
                                        portage.writemsg("Error listing cache entries for " + \
                                                "'%s': %s, continuing...\n" % (mytree, e),
                                                noiselevel=-1)
index b1d4a11b395177378927b901f4bab4b79b2c1886..a38edbd0dde9e05b0b1c550395b691f8db93565b 100644 (file)
@@ -195,7 +195,7 @@ class _PackageMetadataWrapper(dict):
                        elif k in self._use_conditional_keys:
                                try:
                                        use_reduce(paren_reduce(v), matchall=1)
-                               except portage.exception.InvalidDependString, e:
+                               except portage.exception.InvalidDependString as e:
                                        self._pkg._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
 
        def __getitem__(self, k):
index fdd59e1497f409bb7288830fb25347fd656606bd..59bb50e56274a522fde23ec7d25bca6d1336cad9 100644 (file)
@@ -23,7 +23,7 @@ class PackageUninstall(AsynchronousTask):
                                [self.pkg.cpv], self.ldpath_mtimes, clean_world=0,
                                clean_delay=0, raise_on_error=1, scheduler=self.scheduler,
                                writemsg_level=self._writemsg_level)
-               except UninstallFailure, e:
+               except UninstallFailure as e:
                        self.returncode = e.status
                else:
                        self.returncode = os.EX_OK
index 8250cb00a3a49b239fd809d8193c8554c96cd98e..e04b58ae79c719f7a94b15a2d4116edcf296a50a 100644 (file)
@@ -95,7 +95,7 @@ class PollScheduler(object):
                        try:
                                self._poll_event_queue.extend(self._poll_obj.poll(timeout))
                                break
-                       except select.error, e:
+                       except select.error as e:
                                writemsg_level("\n!!! select error: %s\n" % (e,),
                                        level=logging.ERROR, noiselevel=-1)
                                del e
index 06074c932511b226bbd3cb92fff739dcd60ef0ee..d532335e63b39f7cffb1e4f9a811b7adcdd651fe 100644 (file)
@@ -1498,7 +1498,7 @@ class Scheduler(PollScheduler):
                        success, mydepgraph, dropped_tasks = resume_depgraph(
                                self.settings, self.trees, self._mtimedb, self.myopts,
                                myparams, self._spinner)
-               except depgraph.UnsatisfiedResumeDep, exc:
+               except depgraph.UnsatisfiedResumeDep as exc:
                        # rename variable to avoid python-3.0 error:
                        # SyntaxError: can not delete variable 'e' referenced in nested
                        #              scope
index e6b3cc7a0633cccd2a1c1cc3492c2a1c97b7d0d0..70d3ff11dda7773055add908217c70e92f8de79d 100644 (file)
@@ -157,7 +157,7 @@ class SpawnProcess(SubProcess):
                                                                write_successful = True
                                                        files.stdout.flush()
                                                        break
-                                               except IOError, e:
+                                               except IOError as e:
                                                        if e.errno != errno.EAGAIN:
                                                                raise
                                                        del e
index 6bd4562d42996a2cc0af74caa415e04e39cc6809..0df94b9e7c16c1a14790b0555818d5e9908e459b 100644 (file)
@@ -27,7 +27,7 @@ class SubProcess(AbstractPollTask):
 
                try:
                        retval = os.waitpid(self.pid, os.WNOHANG)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ECHILD:
                                raise
                        del e
@@ -42,7 +42,7 @@ class SubProcess(AbstractPollTask):
                if self.isAlive():
                        try:
                                os.kill(self.pid, signal.SIGTERM)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ESRCH:
                                        raise
                                del e
@@ -69,7 +69,7 @@ class SubProcess(AbstractPollTask):
 
                try:
                        wait_retval = os.waitpid(self.pid, 0)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ECHILD:
                                raise
                        del e
index e1f7ffe19e1624913eece39aafd60bc1bd0eed4b..9de19cfbda6a2b01bc7ed2ba49f65a700ebfc87d 100644 (file)
@@ -204,7 +204,7 @@ def action_build(settings, trees, mtimedb,
                        success, mydepgraph, dropped_tasks = resume_depgraph(
                                settings, trees, mtimedb, myopts, myparams, spinner)
                except (portage.exception.PackageNotFound,
-                       depgraph.UnsatisfiedResumeDep), e:
+                       depgraph.UnsatisfiedResumeDep) as e:
                        if isinstance(e, depgraph.UnsatisfiedResumeDep):
                                mydepgraph = e.depgraph
                        if show_spinner:
@@ -298,7 +298,7 @@ def action_build(settings, trees, mtimedb,
                try:
                        success, mydepgraph, favorites = backtrack_depgraph(
                                settings, trees, myopts, myparams, myaction, myfiles, spinner)
-               except portage.exception.PackageSetNotFound, e:
+               except portage.exception.PackageSetNotFound as e:
                        if show_spinner:
                                print "\b\b... done!"
                        root_config = trees[settings["ROOT"]]["root_config"]
@@ -484,7 +484,7 @@ def action_config(settings, trees, myopts, myfiles):
        print
        try:
                pkgs = trees[settings["ROOT"]]["vartree"].dbapi.match(myfiles[0])
-       except portage.exception.AmbiguousPackageName, e:
+       except portage.exception.AmbiguousPackageName as e:
                # Multiple matches thrown from cpv_expand
                pkgs = e.args[0]
        if len(pkgs) == 0:
@@ -682,7 +682,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
                                        if args_set.findAtomForPackage(pkg) is None:
                                                world_temp_set.add("=" + pkg.cpv)
                                                continue
-                               except portage.exception.InvalidDependString, e:
+                               except portage.exception.InvalidDependString as e:
                                        show_invalid_depstring_notice(pkg,
                                                pkg.metadata["PROVIDE"], str(e))
                                        del e
@@ -731,7 +731,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
                                if args_set.findAtomForPackage(pkg) is None:
                                        world_temp_set.add("=" + pkg.cpv)
                                        continue
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                show_invalid_depstring_notice(pkg,
                                        pkg.metadata["PROVIDE"], str(e))
                                del e
@@ -1531,11 +1531,11 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
                                tree_data.valid_nodes.add(cpv)
                                try:
                                        src = tree_data.src_db[cpv]
-                               except KeyError, e:
+                               except KeyError as e:
                                        noise.missing_entry(cpv)
                                        del e
                                        continue
-                               except CacheError, ce:
+                               except CacheError as ce:
                                        noise.exception(cpv, ce)
                                        del ce
                                        continue
@@ -1585,7 +1585,7 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
                                try:
                                        inherited = src.get('INHERITED', '')
                                        eclasses = src.get('_eclasses_')
-                               except CacheError, ce:
+                               except CacheError as ce:
                                        noise.exception(cpv, ce)
                                        del ce
                                        continue
@@ -1630,7 +1630,7 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
 
                                try:
                                        tree_data.dest_db[cpv] = src
-                               except CacheError, ce:
+                               except CacheError as ce:
                                        noise.exception(cpv, ce)
                                        del ce
 
@@ -1644,7 +1644,7 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
        for tree_data in porttrees_data:
                try:
                        dead_nodes = set(tree_data.dest_db.iterkeys())
-               except CacheError, e:
+               except CacheError as e:
                        writemsg_level("Error listing cache entries for " + \
                                "'%s': %s, continuing...\n" % (tree_data.path, e),
                                level=logging.ERROR, noiselevel=-1)
@@ -1673,7 +1673,7 @@ def action_regen(settings, portdb, max_jobs, max_load):
        portage.writemsg_stdout("Regenerating cache entries...\n")
        try:
                os.close(sys.stdin.fileno())
-       except SystemExit, e:
+       except SystemExit as e:
                raise # Needed else can't exit
        except:
                pass
@@ -1696,7 +1696,7 @@ def action_search(root_config, myopts, myfiles, spinner):
                for mysearch in myfiles:
                        try:
                                searchinstance.execute(mysearch)
-                       except re.error, comment:
+                       except re.error as comment:
                                print "\n!!! Regular expression error in \"%s\": %s" % ( mysearch, comment )
                                sys.exit(1)
                        searchinstance.output()
@@ -1888,7 +1888,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
 
                try:
                        maxretries=int(settings["PORTAGE_RSYNC_RETRIES"])
-               except SystemExit, e:
+               except SystemExit as e:
                        raise # Needed else can't exit
                except:
                        maxretries=3 #default number of retries
@@ -1928,9 +1928,9 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                                                        ips.append(addrinfo[4][0])
                                        from random import shuffle
                                        shuffle(ips)
-                               except SystemExit, e:
+                               except SystemExit as e:
                                        raise # Needed else can't exit
-                               except Exception, e:
+                               except Exception as e:
                                        print "Notice:",str(e)
                                        dosyncuri=syncuri
 
@@ -1939,9 +1939,9 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                                        dosyncuri = syncuri.replace(
                                                "//" + user_name + hostname + port + "/",
                                                "//" + user_name + ips[0] + port + "/", 1)
-                               except SystemExit, e:
+                               except SystemExit as e:
                                        raise # Needed else can't exit
-                               except Exception, e:
+                               except Exception as e:
                                        print "Notice:",str(e)
                                        dosyncuri=syncuri
 
@@ -2008,7 +2008,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                                                        os.unlink(tmpservertimestampfile)
                                                except OSError:
                                                        pass
-                               except portage.exception.PortageException, e:
+                               except portage.exception.PortageException as e:
                                        # timed out
                                        print e
                                        del e
@@ -2129,7 +2129,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                                sys.exit(1)
                        try:
                                os.rmdir(myportdir)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        sys.stderr.write(
                                                "!!! existing '%s' directory; exiting.\n" % myportdir)
@@ -2224,7 +2224,7 @@ def action_uninstall(settings, trees, ldpath_mtimes,
                        try:
                                valid_atoms.append(
                                        portage.dep_expand(x, mydb=vardb, settings=settings))
-                       except portage.exception.AmbiguousPackageName, e:
+                       except portage.exception.AmbiguousPackageName as e:
                                msg = "The short ebuild name \"" + x + \
                                        "\" is ambiguous.  Please specify " + \
                                        "one of the following " + \
@@ -2326,7 +2326,7 @@ def adjust_config(myopts, settings):
        CLEAN_DELAY = 5
        try:
                CLEAN_DELAY = int(settings.get("CLEAN_DELAY", str(CLEAN_DELAY)))
-       except ValueError, e:
+       except ValueError as e:
                portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
                portage.writemsg("!!! Unable to parse integer: CLEAN_DELAY='%s'\n" % \
                        settings["CLEAN_DELAY"], noiselevel=-1)
@@ -2337,7 +2337,7 @@ def adjust_config(myopts, settings):
        try:
                EMERGE_WARNING_DELAY = int(settings.get(
                        "EMERGE_WARNING_DELAY", str(EMERGE_WARNING_DELAY)))
-       except ValueError, e:
+       except ValueError as e:
                portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
                portage.writemsg("!!! Unable to parse integer: EMERGE_WARNING_DELAY='%s'\n" % \
                        settings["EMERGE_WARNING_DELAY"], noiselevel=-1)
@@ -2367,7 +2367,7 @@ def adjust_config(myopts, settings):
                        portage.writemsg("!!! PORTAGE_DEBUG must be either 0 or 1\n",
                                noiselevel=-1)
                        PORTAGE_DEBUG = 0
-       except ValueError, e:
+       except ValueError as e:
                portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
                portage.writemsg("!!! Unable to parse integer: PORTAGE_DEBUG='%s'\n" %\
                        settings["PORTAGE_DEBUG"], noiselevel=-1)
@@ -2458,7 +2458,7 @@ def git_sync_timestamps(settings, portdir):
        try:
                cache_db = settings.load_best_module("portdbapi.metadbmodule")(
                        portdir, "metadata/cache", portage.auxdbkeys[:], readonly=True)
-       except CacheError, e:
+       except CacheError as e:
                writemsg_level("!!! Unable to instantiate cache: %s\n" % (e,),
                        level=logging.ERROR, noiselevel=-1)
                return 1
@@ -2467,7 +2467,7 @@ def git_sync_timestamps(settings, portdir):
        try:
                ec_names = set(f[:-7] for f in os.listdir(ec_dir) \
                        if f.endswith(".eclass"))
-       except OSError, e:
+       except OSError as e:
                writemsg_level("!!! Unable to list eclasses: %s\n" % (e,),
                        level=logging.ERROR, noiselevel=-1)
                return 1
@@ -2508,7 +2508,7 @@ def git_sync_timestamps(settings, portdir):
                        writemsg_level("!!! Missing cache entry: %s\n" % (cpv,),
                                level=logging.ERROR, noiselevel=-1)
                        continue
-               except CacheError, e:
+               except CacheError as e:
                        writemsg_level("!!! Unable to access cache entry: %s %s\n" % \
                                (cpv, e), level=logging.ERROR, noiselevel=-1)
                        continue
index 0fdf5880a9458075c20554fc4b47a763c7ece94c..2391a92abb0b538eda322a8b75882114adfda129 100644 (file)
@@ -25,7 +25,7 @@ def calc_changelog(ebuildpath,current,next):
                        encoding=_encodings['fs'], errors='strict'),
                        mode='r', encoding=_encodings['repo.content'], errors='replace'
                ).read()
-       except SystemExit, e:
+       except SystemExit as e:
                raise # Needed else can't exit
        except:
                return []
index e4affdf37f122d0a522d8185438398e093962685..ea7d1b305cbd70f73034a18f8a878e777a216652 100644 (file)
@@ -792,7 +792,7 @@ class depgraph(object):
                if True:
                        try:
                                arg_atoms = list(self._iter_atoms_for_pkg(pkg))
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                if not pkg.installed:
                                        show_invalid_depstring_notice(
                                                pkg, pkg.metadata["PROVIDE"], str(e))
@@ -931,7 +931,7 @@ class depgraph(object):
                                        settings.unlock()
                                        settings.setinst(pkg.cpv, pkg.metadata)
                                        settings.lock()
-                               except portage.exception.InvalidDependString, e:
+                               except portage.exception.InvalidDependString as e:
                                        show_invalid_depstring_notice(
                                                pkg, pkg.metadata["PROVIDE"], str(e))
                                        del e
@@ -1079,7 +1079,7 @@ class depgraph(object):
                                        dep_string = list(self._queue_disjunctive_deps(
                                                pkg, dep_root, dep_priority, dep_string))
 
-                               except portage.exception.InvalidDependString, e:
+                               except portage.exception.InvalidDependString as e:
                                        if pkg.installed:
                                                del e
                                                continue
@@ -1096,7 +1096,7 @@ class depgraph(object):
                                        allow_unsatisfied):
                                        return 0
 
-               except portage.exception.AmbiguousPackageName, e:
+               except portage.exception.AmbiguousPackageName as e:
                        pkgs = e.args[0]
                        portage.writemsg("\n\n!!! An atom in the dependencies " + \
                                "is not fully-qualified. Multiple matches:\n\n", noiselevel=-1)
@@ -1135,7 +1135,7 @@ class depgraph(object):
                        selected_atoms = self._select_atoms(dep_root,
                                dep_string, myuse=pkg.use.enabled, parent=pkg,
                                strict=strict, priority=dep_priority)
-               except portage.exception.InvalidDependString, e:
+               except portage.exception.InvalidDependString as e:
                        show_invalid_depstring_notice(pkg, dep_string, str(e))
                        del e
                        if pkg.installed:
@@ -1678,23 +1678,23 @@ class depgraph(object):
                                                                "dependencies for %s\n") % atom)
                                                return 0, myfavorites
 
-                               except portage.exception.MissingSignature, e:
+                               except portage.exception.MissingSignature as e:
                                        portage.writemsg("\n\n!!! A missing gpg signature is preventing portage from calculating the\n")
                                        portage.writemsg("!!! required dependencies. This is a security feature enabled by the admin\n")
                                        portage.writemsg("!!! to aid in the detection of malicious intent.\n\n")
                                        portage.writemsg("!!! THIS IS A POSSIBLE INDICATION OF TAMPERED FILES -- CHECK CAREFULLY.\n")
                                        portage.writemsg("!!! Affected file: %s\n" % (e), noiselevel=-1)
                                        return 0, myfavorites
-                               except portage.exception.InvalidSignature, e:
+                               except portage.exception.InvalidSignature as e:
                                        portage.writemsg("\n\n!!! An invalid gpg signature is preventing portage from calculating the\n")
                                        portage.writemsg("!!! required dependencies. This is a security feature enabled by the admin\n")
                                        portage.writemsg("!!! to aid in the detection of malicious intent.\n\n")
                                        portage.writemsg("!!! THIS IS A POSSIBLE INDICATION OF TAMPERED FILES -- CHECK CAREFULLY.\n")
                                        portage.writemsg("!!! Affected file: %s\n" % (e), noiselevel=-1)
                                        return 0, myfavorites
-                               except SystemExit, e:
+                               except SystemExit as e:
                                        raise # Needed else can't exit
-                               except Exception, e:
+                               except Exception as e:
                                        print >> sys.stderr, "\n\n!!! Problem in '%s' dependencies." % atom
                                        print >> sys.stderr, "!!!", str(e), getattr(e, "__module__", None)
                                        raise
@@ -2648,7 +2648,7 @@ class depgraph(object):
                                                                success, atoms = portage.dep_check(depstr,
                                                                        final_db, pkgsettings, myuse=pkg.use.enabled,
                                                                        trees=self._dynamic_config._graph_trees, myroot=myroot)
-                                                       except Exception, e:
+                                                       except Exception as e:
                                                                if isinstance(e, SystemExit):
                                                                        raise
                                                                # This is helpful, for example, if a ValueError
@@ -2684,7 +2684,7 @@ class depgraph(object):
                                                                blocker = Blocker(atom=portage.dep.Atom(atom),
                                                                        eapi=pkg.metadata["EAPI"], root=myroot)
                                                                self._dynamic_config._blocker_parents.add(blocker, pkg)
-                                               except portage.exception.InvalidAtom, e:
+                                               except portage.exception.InvalidAtom as e:
                                                        depstr = " ".join(vardb.aux_get(pkg.cpv, dep_keys))
                                                        show_invalid_depstring_notice(
                                                                pkg, depstr, "Invalid Atom: %s" % (e,))
@@ -3055,7 +3055,7 @@ class depgraph(object):
                                        running_root, running_portage.metadata["RDEPEND"],
                                        myuse=running_portage.use.enabled,
                                        parent=running_portage, strict=False)
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                portage.writemsg("!!! Invalid RDEPEND in " + \
                                        "'%svar/db/pkg/%s/RDEPEND': %s\n" % \
                                        (running_root, running_portage.cpv, e), noiselevel=-1)
@@ -3291,7 +3291,7 @@ class depgraph(object):
                                                try:
                                                        runtime_dep_atoms = \
                                                                list(runtime_deps.iterAtomsForPackage(task))
-                                               except portage.exception.InvalidDependString, e:
+                                               except portage.exception.InvalidDependString as e:
                                                        portage.writemsg("!!! Invalid PROVIDE in " + \
                                                                "'%svar/db/pkg/%s/PROVIDE': %s\n" % \
                                                                (task.root, task.cpv, e), noiselevel=-1)
@@ -3326,7 +3326,7 @@ class depgraph(object):
                                                                "system"].iterAtomsForPackage(task):
                                                                skip = True
                                                                break
-                                               except portage.exception.InvalidDependString, e:
+                                               except portage.exception.InvalidDependString as e:
                                                        portage.writemsg("!!! Invalid PROVIDE in " + \
                                                                "'%svar/db/pkg/%s/PROVIDE': %s\n" % \
                                                                (task.root, task.cpv, e), noiselevel=-1)
@@ -3361,7 +3361,7 @@ class depgraph(object):
                                                                        skip = True
                                                                        self._dynamic_config._blocked_world_pkgs[inst_pkg] = atom
                                                                        break
-                                               except portage.exception.InvalidDependString, e:
+                                               except portage.exception.InvalidDependString as e:
                                                        portage.writemsg("!!! Invalid PROVIDE in " + \
                                                                "'%svar/db/pkg/%s/PROVIDE': %s\n" % \
                                                                (task.root, task.cpv, e), noiselevel=-1)
@@ -4196,7 +4196,7 @@ class depgraph(object):
                                                try:
                                                        myfilesdict = portdb.getfetchsizes(pkg_key,
                                                                useflags=pkg_use, debug=self._frozen_config.edebug)
-                                               except portage.exception.InvalidDependString, e:
+                                               except portage.exception.InvalidDependString as e:
                                                        src_uri = portdb.aux_get(pkg_key, ["SRC_URI"])[0]
                                                        show_invalid_depstring_notice(x, src_uri, str(e))
                                                        del e
@@ -4252,7 +4252,7 @@ class depgraph(object):
                                if "COLUMNWIDTH" in self._frozen_config.settings:
                                        try:
                                                mywidth = int(self._frozen_config.settings["COLUMNWIDTH"])
-                                       except ValueError, e:
+                                       except ValueError as e:
                                                portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
                                                portage.writemsg(
                                                        "!!! Unable to parse COLUMNWIDTH='%s'\n" % \
@@ -4601,7 +4601,7 @@ class depgraph(object):
                                        if myfavkey in added_favorites:
                                                continue
                                        added_favorites.add(myfavkey)
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                writemsg("\n\n!!! '%s' has invalid PROVIDE: %s\n" % \
                                        (pkg_key, str(e)), noiselevel=-1)
                                writemsg("!!! see '%s'\n\n" % os.path.join(
@@ -5080,7 +5080,7 @@ def resume_depgraph(settings, trees, mtimedb, myopts, myparams, spinner):
                try:
                        success = mydepgraph._loadResumeCommand(mtimedb["resume"],
                                skip_masked=skip_masked)
-               except depgraph.UnsatisfiedResumeDep, e:
+               except depgraph.UnsatisfiedResumeDep as e:
                        if not skip_unsatisfied:
                                raise
 
index cdc60767b7705f93610ad2daa86b55b70400743e..4e9a2e93e74212d908dc2cefa8608822ca909620 100644 (file)
@@ -46,6 +46,6 @@ def emergelog(xterm_titles, mystr, short_msg=None):
                        if mylock:
                                portage.locks.unlockfile(mylock)
                        mylogfile.close()
-       except (IOError,OSError,portage.exception.PortageException), e:
+       except (IOError,OSError,portage.exception.PortageException) as e:
                if secpass >= 1:
                        print >> sys.stderr, "emergelog():",e
index 6307904b759784ce564d1848279ed80c313d7792..0df815a02b3733554d27c11e71267ea8552bc729 100644 (file)
@@ -137,7 +137,7 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
                                                        try:
                                                                os.rename(dir_file + ext, dir_file + ext + ".old")
                                                                moved_old_dir = True
-                                                       except EnvironmentError, e:
+                                                       except EnvironmentError as e:
                                                                if e.errno != errno.ENOENT:
                                                                        raise
                                                                del e
@@ -164,7 +164,7 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
                                        for ext in dir_extensions:
                                                try:
                                                        os.rename(dir_file + ext + ".old", dir_file + ext)
-                                               except EnvironmentError, e:
+                                               except EnvironmentError as e:
                                                        if e.errno != errno.ENOENT:
                                                                raise
                                                        del e
@@ -174,7 +174,7 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
                                for ext in dir_extensions:
                                        try:
                                                os.unlink(dir_file + ext + ".old")
-                                       except EnvironmentError, e:
+                                       except EnvironmentError as e:
                                                if e.errno != errno.ENOENT:
                                                        raise
                                                del e
@@ -213,7 +213,7 @@ def display_preserved_libs(vardbapi, myopts):
 
                try:
                        linkmap.rebuild()
-               except portage.exception.CommandNotFound, e:
+               except portage.exception.CommandNotFound as e:
                        writemsg_level("!!! Command Not Found: %s\n" % (e,),
                                level=logging.ERROR, noiselevel=-1)
                        del e
@@ -783,7 +783,7 @@ def apply_priorities(settings):
 def nice(settings):
        try:
                os.nice(int(settings.get("PORTAGE_NICENESS", "0")))
-       except (OSError, ValueError), e:
+       except (OSError, ValueError) as e:
                out = portage.output.EOutput()
                out.eerror("Failed to change nice value to '%s'" % \
                        settings["PORTAGE_NICENESS"])
@@ -910,7 +910,7 @@ def expand_set_arguments(myfiles, myaction, root_config):
                                setconfig.active.append(s)
                                try:
                                        set_atoms = setconfig.getSetAtoms(s)
-                               except portage.exception.PackageSetNotFound, e:
+                               except portage.exception.PackageSetNotFound as e:
                                        writemsg_level(("emerge: the given set '%s' " + \
                                                "contains a non-existent set named '%s'.\n") % \
                                                (s, e), level=logging.ERROR, noiselevel=-1)
@@ -1281,7 +1281,7 @@ def emerge_main():
                        try:
                                # At least the parent needs to exist for the lock file.
                                portage.util.ensure_dirs(settings['EMERGE_LOG_DIR'])
-                       except portage.exception.PortageException, e:
+                       except portage.exception.PortageException as e:
                                writemsg_level("!!! Error creating directory for " + \
                                        "EMERGE_LOG_DIR='%s':\n!!! %s\n" % \
                                        (settings['EMERGE_LOG_DIR'], e),
@@ -1364,7 +1364,7 @@ def emerge_main():
                                try:
                                        valid_atoms.append(
                                                portage.dep_expand(x, mydb=vardb, settings=settings))
-                               except portage.exception.AmbiguousPackageName, e:
+                               except portage.exception.AmbiguousPackageName as e:
                                        msg = "The short ebuild name \"" + x + \
                                                "\" is ambiguous.  Please specify " + \
                                                "one of the following " + \
index 1f276b47e2767a1768da0b1c6b234c57762a2df3..9f0811dea63eaf393ce407d233e66677c0d6dc75 100644 (file)
@@ -315,13 +315,13 @@ class search(object):
                                                        pkgdir, self.settings["DISTDIR"])
                                                try:
                                                        uri_map = self.portdb.getFetchMap(mycpv)
-                                               except portage.exception.InvalidDependString, e:
+                                               except portage.exception.InvalidDependString as e:
                                                        file_size_str = "Unknown (%s)" % (e,)
                                                        del e
                                                else:
                                                        try:
                                                                mysum[0] = mf.getDistfilesSize(uri_map)
-                                                       except KeyError, e:
+                                                       except KeyError as e:
                                                                file_size_str = "Unknown (missing " + \
                                                                        "digest for %s)" % (e,)
                                                                del e
index cfa57bbc7105d4b844555de8f9fbb095cfd4caf4..76b3795819e35718053d8b8b99753c87316752d0 100644 (file)
@@ -171,7 +171,7 @@ def unmerge(root_config, myopts, unmerge_action,
                        # what will and will not get unmerged
                        try:
                                mymatch = vartree.dbapi.match(x)
-                       except portage.exception.AmbiguousPackageName, errpkgs:
+                       except portage.exception.AmbiguousPackageName as errpkgs:
                                print "\n\n!!! The short ebuild name \"" + \
                                        x + "\" is ambiguous.  Please specify"
                                print "!!! one of the following fully-qualified " + \
index b7c4e9e445e7e38f0940f92d4717a8c056710647..f2a810531429109325202db1634e71eced5e64e8 100644 (file)
@@ -42,7 +42,7 @@ try:
        import shutil
        del shutil
 
-except ImportError, e:
+except ImportError as e:
        sys.stderr.write("\n\n")
        sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n")
        sys.stderr.write("!!! python and failure here indicates that you have a problem with python\n")
@@ -108,7 +108,7 @@ try:
 
        from portage.localization import _
 
-except ImportError, e:
+except ImportError as e:
        sys.stderr.write("\n\n")
        sys.stderr.write("!!! Failed to complete portage imports. There are internal modules for\n")
        sys.stderr.write("!!! portage and failure here indicates that you have a problem with your\n")
@@ -257,7 +257,7 @@ try:
                encoding=_encodings['fs'])
        _selinux_merge = _unicode_module_wrapper(_selinux,
                encoding=_encodings['merge'])
-except OSError, e:
+except OSError as e:
        sys.stderr.write("!!! SELinux not loaded: %s\n" % str(e))
        del e
 except ImportError:
@@ -513,7 +513,7 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        mtime = pathstat.st_mtime
                else:
                        raise portage.exception.DirectoryNotFound(mypath)
-       except EnvironmentError, e:
+       except EnvironmentError as e:
                if e.errno == portage.exception.PermissionDenied.errno:
                        raise portage.exception.PermissionDenied(mypath)
                del e
@@ -530,7 +530,7 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        cacheStale += 1
                try:
                        list = os.listdir(mypath)
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        if e.errno != errno.EACCES:
                                raise
                        del e
@@ -966,7 +966,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
                file_path = os.path.join(envd_dir, x)
                try:
                        myconfig = getconfig(file_path, expand=False)
-               except portage.exception.ParseError, e:
+               except portage.exception.ParseError as e:
                        writemsg("!!! '%s'\n" % str(e), noiselevel=-1)
                        del e
                        continue
@@ -1027,7 +1027,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
                        if x[0]=="#":
                                continue
                        oldld.append(x[:-1])
-       except (IOError, OSError), e:
+       except (IOError, OSError) as e:
                if e.errno != errno.ENOENT:
                        raise
                oldld = None
@@ -1087,7 +1087,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
                try:
                        newldpathtime = long(os.stat(x).st_mtime)
                        lib_dirs.add(normalize_path(x))
-               except OSError, oe:
+               except OSError as oe:
                        if oe.errno == errno.ENOENT:
                                try:
                                        del prev_mtimes[x]
@@ -1202,17 +1202,17 @@ def ExtractKernelVersion(base_dir):
                f = codecs.open(_unicode_encode(pathname,
                        encoding=_encodings['fs'], errors='strict'), mode='r',
                        encoding=_encodings['content'], errors='replace')
-       except OSError, details:
+       except OSError as details:
                return (None, str(details))
-       except IOError, details:
+       except IOError as details:
                return (None, str(details))
 
        try:
                for i in range(4):
                        lines.append(f.readline())
-       except OSError, details:
+       except OSError as details:
                return (None, str(details))
-       except IOError, details:
+       except IOError as details:
                return (None, str(details))
 
        lines = [l.strip() for l in lines]
@@ -1687,7 +1687,7 @@ class config(object):
                                        self.profiles.append(currentPath)
                                try:
                                        addProfile(os.path.realpath(self.profile_path))
-                               except portage.exception.ParseError, e:
+                               except portage.exception.ParseError as e:
                                        writemsg(_("!!! Unable to parse profile: '%s'\n") % \
                                                self.profile_path, noiselevel=-1)
                                        writemsg("!!! ParseError: %s\n" % str(e), noiselevel=-1)
@@ -1999,11 +1999,11 @@ class config(object):
                                                encoding=_encodings['fs'], errors='strict'),
                                                mode='r', encoding=_encodings['content'], errors='replace')
                                        )
-                               except EnvironmentError, e:
+                               except EnvironmentError as e:
                                        if e.errno != errno.ENOENT:
                                                raise
                                        del e
-                               except ParsingError, e:
+                               except ParsingError as e:
                                        portage.util.writemsg_level(
                                                _("!!! Error parsing '%s': %s\n")  % \
                                                (self._local_repo_conf_path, e),
@@ -2198,7 +2198,7 @@ class config(object):
                                continue
                        try:
                                portage.util.ensure_dirs(mydir, gid=gid, mode=mode, mask=modemask)
-                       except portage.exception.PortageException, e:
+                       except portage.exception.PortageException as e:
                                writemsg(_("!!! Directory initialization failed: '%s'\n") % mydir,
                                        noiselevel=-1)
                                writemsg("!!! %s\n" % str(e),
@@ -3138,7 +3138,7 @@ class config(object):
                        elif len(accept_chost) == 1:
                                try:
                                        self._accept_chost_re = re.compile(r'^%s$' % accept_chost[0])
-                               except re.error, e:
+                               except re.error as e:
                                        writemsg(_("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n") % \
                                                (accept_chost[0], e), noiselevel=-1)
                                        self._accept_chost_re = re.compile("^$")
@@ -3146,7 +3146,7 @@ class config(object):
                                try:
                                        self._accept_chost_re = re.compile(
                                                r'^(%s)$' % "|".join(accept_chost))
-                               except re.error, e:
+                               except re.error as e:
                                        writemsg(_("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n") % \
                                                (" ".join(accept_chost), e), noiselevel=-1)
                                        self._accept_chost_re = re.compile("^$")
@@ -3739,7 +3739,7 @@ def _create_pty_or_pipe(copy_term_size=None):
                try:
                        master_fd, slave_fd = openpty()
                        got_pty = True
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        _disable_openpty = True
                        writemsg("openpty failed: '%s'\n" % str(e),
                                noiselevel=-1)
@@ -4396,7 +4396,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                filemode=filemode, filemask=modemask, onerror=onerror):
                                                raise portage.exception.OperationNotPermitted(
                                                        _("Failed to apply recursive permissions for the portage group."))
-               except portage.exception.PortageException, e:
+               except portage.exception.PortageException as e:
                        if not os.path.isdir(mysettings["DISTDIR"]):
                                writemsg("!!! %s\n" % str(e), noiselevel=-1)
                                writemsg(_("!!! Directory Not Found: DISTDIR='%s'\n") % mysettings["DISTDIR"], noiselevel=-1)
@@ -4456,7 +4456,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                vfs_stat = os.statvfs(mysettings["DISTDIR"])
                                try:
                                        mysize = os.stat(myfile_path).st_size
-                               except OSError, e:
+                               except OSError as e:
                                        if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                raise
                                        del e
@@ -4520,7 +4520,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                        apply_secpass_permissions(myfile_path,
                                                                gid=portage_gid, mode=0664, mask=02,
                                                                stat_cached=mystat)
-                                               except portage.exception.PortageException, e:
+                                               except portage.exception.PortageException as e:
                                                        if not os.access(myfile_path, os.R_OK):
                                                                writemsg(_("!!! Failed to adjust permissions:"
                                                                        " %s\n") % str(e), noiselevel=-1)
@@ -4589,7 +4589,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        if readonly_file is not None:
                                                try:
                                                        os.unlink(myfile_path)
-                                               except OSError, e:
+                                               except OSError as e:
                                                        if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
@@ -4603,14 +4603,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                        shutil.copyfile(mirror_file, myfile_path)
                                                        writemsg(_("Local mirror has file: %s\n") % myfile)
                                                        break
-                                               except (IOError, OSError), e:
+                                               except (IOError, OSError) as e:
                                                        if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
 
                                try:
                                        mystat = os.stat(myfile_path)
-                               except OSError, e:
+                               except OSError as e:
                                        if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                raise
                                        del e
@@ -4619,7 +4619,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                apply_secpass_permissions(
                                                        myfile_path, gid=portage_gid, mode=0664, mask=02,
                                                        stat_cached=mystat)
-                                       except portage.exception.PortageException, e:
+                                       except portage.exception.PortageException as e:
                                                if not os.access(myfile_path, os.R_OK):
                                                        writemsg(_("!!! Failed to adjust permissions:"
                                                                " %s\n") % str(e), noiselevel=-1)
@@ -4754,7 +4754,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        if fetched != 2:
                                                try:
                                                        mysize = os.stat(myfile_path).st_size
-                                               except OSError, e:
+                                               except OSError as e:
                                                        if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
@@ -4778,7 +4778,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        if fetched == 1:
                                                try:
                                                        mystat = os.stat(myfile_path)
-                                               except OSError, e:
+                                               except OSError as e:
                                                        if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
@@ -4790,7 +4790,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                                        "ME_MIN_SIZE)\n") % mystat.st_size)
                                                                try:
                                                                        os.unlink(myfile_path)
-                                                               except OSError, e:
+                                                               except OSError as e:
                                                                        if e.errno not in \
                                                                                (errno.ENOENT, errno.ESTALE):
                                                                                raise
@@ -4824,9 +4824,9 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                try:
                                                        apply_secpass_permissions(myfile_path,
                                                                gid=portage_gid, mode=0664, mask=02)
-                                               except portage.exception.FileNotFound, e:
+                                               except portage.exception.FileNotFound as e:
                                                        pass
-                                               except portage.exception.PortageException, e:
+                                               except portage.exception.PortageException as e:
                                                        if not os.access(myfile_path, os.R_OK):
                                                                writemsg(_("!!! Failed to adjust permissions:"
                                                                        " %s\n") % str(e), noiselevel=-1)
@@ -4845,7 +4845,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        if mydigests is not None and myfile in mydigests:
                                                try:
                                                        mystat = os.stat(myfile_path)
-                                               except OSError, e:
+                                               except OSError as e:
                                                        if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
@@ -4987,7 +4987,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        try:
                                                private_tmpdir = mkdtemp("", "._portage_fetch_.",
                                                        global_tmpdir)
-                                       except OSError, e:
+                                       except OSError as e:
                                                if e.errno != portage.exception.PermissionDenied.errno:
                                                        raise
                                                raise portage.exception.PermissionDenied(global_tmpdir)
@@ -5067,7 +5067,7 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
                        try:
                                for myfile in fetchlist_dict[cpv]:
                                        distfiles_map.setdefault(myfile, []).append(cpv)
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                writemsg("!!! %s\n" % str(e), noiselevel=-1)
                                del e
                                return 0
@@ -5106,7 +5106,7 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
 
                        try:
                                st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -5169,16 +5169,16 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
                                assumeDistHashesSometimes=True,
                                assumeDistHashesAlways=(
                                "assume-digests" in mysettings.features))
-               except portage.exception.FileNotFound, e:
+               except portage.exception.FileNotFound as e:
                        writemsg(_("!!! File %s doesn't exist, can't update "
                                "Manifest\n") % e, noiselevel=-1)
                        return 0
-               except portage.exception.PortagePackageException, e:
+               except portage.exception.PortagePackageException as e:
                        writemsg(("!!! %s\n") % (e,), noiselevel=-1)
                        return 0
                try:
                        mf.write(sign=False)
-               except portage.exception.PermissionDenied, e:
+               except portage.exception.PermissionDenied as e:
                        writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
                        return 0
                if "assume-digests" not in mysettings.features:
@@ -5277,16 +5277,16 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
                                raise KeyError(f)
                        mf.checkFileHashes(ftype, f)
                        eout.eend(0)
-       except KeyError, e:
+       except KeyError as e:
                eout.eend(1)
                writemsg(_("\n!!! Missing digest for %s\n") % str(e), noiselevel=-1)
                return 0
-       except portage.exception.FileNotFound, e:
+       except portage.exception.FileNotFound as e:
                eout.eend(1)
                writemsg(_("\n!!! A file listed in the Manifest could not be found: %s\n") % str(e),
                        noiselevel=-1)
                return 0
-       except portage.exception.DigestException, e:
+       except portage.exception.DigestException as e:
                eout.eend(1)
                writemsg(_("\n!!! Digest verification failed:\n"), noiselevel=-1)
                writemsg("!!! %s\n" % e.value[0], noiselevel=-1)
@@ -6035,7 +6035,7 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
        for clean_dir in clean_dirs:
                try:
                        shutil.rmtree(clean_dir)
-               except OSError, oe:
+               except OSError as oe:
                        if errno.ENOENT == oe.errno:
                                pass
                        elif errno.EPERM == oe.errno:
@@ -6049,7 +6049,7 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
        def makedirs(dir_path):
                try:
                        os.makedirs(dir_path)
-               except OSError, oe:
+               except OSError as oe:
                        if errno.EEXIST == oe.errno:
                                pass
                        elif errno.EPERM == oe.errno:
@@ -6080,13 +6080,13 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
                        portage.util.ensure_dirs(mysettings[dir_key], mode=0775)
                        portage.util.apply_secpass_permissions(mysettings[dir_key],
                                uid=portage_uid, gid=portage_gid)
-       except portage.exception.PermissionDenied, e:
+       except portage.exception.PermissionDenied as e:
                writemsg(_("Permission Denied: %s\n") % str(e), noiselevel=-1)
                return 1
-       except portage.exception.OperationNotPermitted, e:
+       except portage.exception.OperationNotPermitted as e:
                writemsg(_("Operation Not Permitted: %s\n") % str(e), noiselevel=-1)
                return 1
-       except portage.exception.FileNotFound, e:
+       except portage.exception.FileNotFound as e:
                writemsg(_("File Not Found: '%s'\n") % str(e), noiselevel=-1)
                return 1
 
@@ -6209,14 +6209,14 @@ def _prepare_features_dirs(mysettings):
                                                        raise portage.exception.OperationNotPermitted(
                                                                _("Failed to apply recursive permissions for the portage group."))
 
-                       except portage.exception.DirectoryNotFound, e:
+                       except portage.exception.DirectoryNotFound as e:
                                failure = True
                                writemsg(_("\n!!! Directory does not exist: '%s'\n") % \
                                        (e,), noiselevel=-1)
                                writemsg(_("!!! Disabled FEATURES='%s'\n") % myfeature,
                                        noiselevel=-1)
 
-                       except portage.exception.PortageException, e:
+                       except portage.exception.PortageException as e:
                                failure = True
                                writemsg("\n!!! %s\n" % str(e), noiselevel=-1)
                                writemsg(_("!!! Failed resetting perms on %s='%s'\n") % \
@@ -6243,9 +6243,9 @@ def _prepare_workdir(mysettings):
                        raise ValueError("Invalid file mode: %s" % mode)
                else:
                        workdir_mode = parsed_mode
-       except KeyError, e:
+       except KeyError as e:
                writemsg(_("!!! PORTAGE_WORKDIR_MODE is unset, using %s.\n") % oct(workdir_mode))
-       except ValueError, e:
+       except ValueError as e:
                if len(str(e)) > 0:
                        writemsg("%s\n" % e)
                writemsg(_("!!! Unable to parse PORTAGE_WORKDIR_MODE='%s', using %s.\n") % \
@@ -6266,7 +6266,7 @@ def _prepare_workdir(mysettings):
                        if modified:
                                apply_secpass_permissions(mysettings["PORT_LOGDIR"],
                                        uid=portage_uid, gid=portage_gid, mode=02770)
-               except portage.exception.PortageException, e:
+               except portage.exception.PortageException as e:
                        writemsg("!!! %s\n" % str(e), noiselevel=-1)
                        writemsg(_("!!! Permission issues with PORT_LOGDIR='%s'\n") % \
                                mysettings["PORT_LOGDIR"], noiselevel=-1)
@@ -6518,7 +6518,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                "could not be found: '%s'") % (myebuild,))
                        _doebuild_broken_ebuilds.add(myebuild)
                        return 1
-               except portage.exception.DigestException, e:
+               except portage.exception.DigestException as e:
                        out = portage.output.EOutput()
                        out.eerror(_("Digest verification failed:"))
                        out.eerror("%s" % e.value[0])
@@ -6729,7 +6729,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                        saved_env = None
                        try:
                                env_stat = os.stat(env_file)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -6745,7 +6745,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                        _shell_quote(env_file)))
                                try:
                                        env_stat = os.stat(env_file)
-                               except OSError, e:
+                               except OSError as e:
                                        if e.errno != errno.ENOENT:
                                                raise
                                        del e
@@ -6762,7 +6762,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                                saved_env, noiselevel=-1)
                                        try:
                                                os.unlink(env_file)
-                                       except OSError, e:
+                                       except OSError as e:
                                                if e.errno != errno.ENOENT:
                                                        raise
                                                del e
@@ -6888,7 +6888,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                alist = mydbapi.getFetchMap(mycpv, useflags=useflags,
                                        mytree=mytree)
                                aalist = mydbapi.getFetchMap(mycpv, mytree=mytree)
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                writemsg("!!! %s\n" % str(e), noiselevel=-1)
                                writemsg(_("!!! Invalid SRC_URI for '%s'.\n") % mycpv,
                                        noiselevel=-1)
@@ -6932,7 +6932,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                # for fetch (especially parallel-fetch) since it's not needed
                                # and it can interfere with parallel tasks.
                                digestgen(aalist, mysettings, overwrite=0, myportdb=mydbapi)
-               except portage.exception.PermissionDenied, e:
+               except portage.exception.PermissionDenied as e:
                        writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
                        if mydo in ("digest", "manifest"):
                                return 1
@@ -7131,7 +7131,7 @@ def _validate_deps(mysettings, myroot, mydo, mydbapi):
                try:
                        portage.dep.use_reduce(
                                portage.dep.paren_reduce(metadata[k]), matchall=True)
-               except portage.exception.InvalidDependString, e:
+               except portage.exception.InvalidDependString as e:
                        msgs.append("  %s: %s\n    %s\n" % (
                                k, metadata[k], str(e)))
 
@@ -7181,9 +7181,9 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                if not sstat:
                        sstat=os.lstat(src)
 
-       except SystemExit, e:
+       except SystemExit as e:
                raise
-       except Exception, e:
+       except Exception as e:
                print _("!!! Stating source file failed... movefile()")
                print "!!!",e
                return None
@@ -7209,9 +7209,9 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                        try:
                                os.unlink(dest)
                                destexists=0
-                       except SystemExit, e:
+                       except SystemExit as e:
                                raise
-                       except Exception, e:
+                       except Exception as e:
                                pass
 
        if stat.S_ISLNK(sstat[stat.ST_MODE]):
@@ -7230,9 +7230,9 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                        # utime() only works on the target of a symlink, so it's not
                        # possible to perserve mtime on symlinks.
                        return os.lstat(dest)[stat.ST_MTIME]
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
-               except Exception, e:
+               except Exception as e:
                        print _("!!! failed to properly create symlink:")
                        print "!!!",dest,"->",target
                        print "!!!",e
@@ -7249,7 +7249,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                        (tail, os.getpid()))
                try:
                        os.unlink(hardlink_tmp)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ENOENT:
                                writemsg(_("!!! Failed to remove hardlink temp file: %s\n") % \
                                        (hardlink_tmp,), noiselevel=-1)
@@ -7264,7 +7264,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                        else:
                                try:
                                        os.rename(hardlink_tmp, dest)
-                               except OSError, e:
+                               except OSError as e:
                                        writemsg(_("!!! Failed to rename %s to %s\n") % \
                                                (hardlink_tmp, dest), noiselevel=-1)
                                        writemsg("!!! %s\n" % (e,), noiselevel=-1)
@@ -7282,9 +7282,9 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                        else:
                                ret=os.rename(src,dest)
                        renamefailed=0
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
-               except Exception, e:
+               except Exception as e:
                        if e[0]!=errno.EXDEV:
                                # Some random error.
                                print _("!!! Failed to move %(src)s to %(dest)s") % {"src": src, "dest": dest}
@@ -7302,9 +7302,9 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                                        shutil.copyfile(src,dest+"#new")
                                        os.rename(dest+"#new",dest)
                                didcopy=1
-                       except SystemExit, e:
+                       except SystemExit as e:
                                raise
-                       except Exception, e:
+                       except Exception as e:
                                print _('!!! copy %(src)s -> %(dest)s failed.') % {"src": src, "dest": dest}
                                print "!!!",e
                                return None
@@ -7326,9 +7326,9 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                                        os.chown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
                                os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
                                os.unlink(src)
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
-               except Exception, e:
+               except Exception as e:
                        print _("!!! Failed to chown/chmod/unlink in movefile()")
                        print "!!!",dest
                        print "!!!",e
@@ -7348,7 +7348,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                # Instead of failing, use stat to return the mtime if possible.
                try:
                        newmtime = long(os.stat(dest).st_mtime)
-               except OSError, e:
+               except OSError as e:
                        writemsg(_("!!! Failed to stat in movefile()\n"), noiselevel=-1)
                        writemsg("!!! %s\n" % dest, noiselevel=-1)
                        writemsg("!!! %s\n" % str(e), noiselevel=-1)
@@ -7905,7 +7905,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
        #convert parenthesis to sublists
        try:
                mysplit = portage.dep.paren_reduce(depstring)
-       except portage.exception.InvalidDependString, e:
+       except portage.exception.InvalidDependString as e:
                return [0, str(e)]
 
        mymasks = set()
@@ -7927,7 +7927,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
        try:
                mysplit = portage.dep.use_reduce(mysplit, uselist=myusesplit,
                        masklist=mymasks, matchall=(use=="all"), excludeall=useforce)
-       except portage.exception.InvalidDependString, e:
+       except portage.exception.InvalidDependString as e:
                return [0, str(e)]
 
        # Do the || conversions
@@ -7944,7 +7944,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
                        use=use, mode=mode, myuse=myuse,
                        use_force=useforce, use_mask=mymasks, use_cache=use_cache,
                        use_binaries=use_binaries, myroot=myroot, trees=trees)
-       except portage.exception.ParseError, e:
+       except portage.exception.ParseError as e:
                return [0, str(e)]
 
        mysplit2=mysplit[:]
@@ -7959,7 +7959,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
        try:
                selected_atoms = dep_zapdeps(mysplit, mysplit2, myroot,
                        use_binaries=use_binaries, trees=trees)
-       except portage.exception.InvalidAtom, e:
+       except portage.exception.InvalidAtom as e:
                if portage.dep._dep_check_strict:
                        raise # This shouldn't happen.
                # dbapi.match() failed due to an invalid atom in
@@ -8323,7 +8323,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
                        msg = license_split[:]
                        msg.append("license(s)")
                        rValue.append(" ".join(msg))
-       except portage.exception.InvalidDependString, e:
+       except portage.exception.InvalidDependString as e:
                rValue.append("LICENSE: "+str(e))
 
        try:
@@ -8337,7 +8337,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
                        msg = properties_split[:]
                        msg.append("properties")
                        rValue.append(" ".join(msg))
-       except portage.exception.InvalidDependString, e:
+       except portage.exception.InvalidDependString as e:
                rValue.append("PROPERTIES: "+str(e))
 
        # Only show KEYWORDS masks for installed packages
@@ -8442,7 +8442,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
                        uid=portage_uid, gid=portage_gid, mode=070, mask=0)
                try:
                        shutil.rmtree(builddir)
-               except (IOError, OSError), e:
+               except (IOError, OSError) as e:
                        if e.errno != errno.ENOENT:
                                raise
                        del e
@@ -8501,7 +8501,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
                        try:
                                if success:
                                        shutil.rmtree(builddir)
-                       except (IOError, OSError), e:
+                       except (IOError, OSError) as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -8559,7 +8559,7 @@ def commit_mtimedb(mydict=None, filename=None):
                f.close()
                portage.util.apply_secpass_permissions(filename,
                        uid=uid, gid=portage_gid, mode=0644)
-       except (IOError, OSError), e:
+       except (IOError, OSError) as e:
                pass
 
 def portageexit():
@@ -8728,7 +8728,7 @@ class MtimeDB(dict):
                        d = mypickle.load()
                        f.close()
                        del f
-               except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError), e:
+               except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e:
                        if isinstance(e, pickle.UnpicklingError):
                                writemsg(_("!!! Error loading '%s': %s\n") % \
                                        (filename, str(e)), noiselevel=-1)
index 226c6d7d0d52d3fe7faf1a1cec3fe93dadf1738e..5b771adadd73378b96be5f60fbf0b2f2f83b5940 100644 (file)
@@ -38,7 +38,7 @@ class database(fs_template.FsBased):
                        try:
                                self._ensure_dirs()
                                self._ensure_dirs(self._db_path)
-                       except (OSError, IOError), e:
+                       except (OSError, IOError) as e:
                                raise cache_errors.InitializationError(self.__class__, e)
 
                        # try again if failed
@@ -46,7 +46,7 @@ class database(fs_template.FsBased):
                                if self.__db == None:
                                        self.__db = anydbm_module.open(
                                                _unicode_encode(self._db_path), 'c', self._perms)
-                       except anydbm_module.error, e:
+                       except anydbm_module.error as e:
                                raise cache_errors.InitializationError(self.__class__, e)
                self._ensure_access(self._db_path)
 
index fa3937e2fbf125a4b44aeaaa9eb8d2a065806968..4bcc6c8466b25c2afad434ff19a95b047d51ac35 100644 (file)
@@ -35,7 +35,7 @@ class database(fs_template.FsBased):
                path = os.path.join(self.portdir,'profiles/repo_name')
                try:
                        return int(self.__get(path,'value_max_len'))
-               except NoValueException,e:
+               except NoValueException as e:
                        max = self.__calc_max(path)
                        self.__set(path,'value_max_len',str(max))
                        return max
@@ -54,7 +54,7 @@ class database(fs_template.FsBased):
                        while True:
                                self.__set(path,'test_max',s)
                                s+=hundred
-               except IOError,e:
+               except IOError as e:
                        # ext based give wrong errno
                        # http://bugzilla.kernel.org/show_bug.cgi?id=12793
                        if e.errno in (E2BIG,ENOSPC):
@@ -64,7 +64,7 @@ class database(fs_template.FsBased):
 
                try:
                        self.__remove(path,'test_max')
-               except IOError,e:
+               except IOError as e:
                        if e.errno is not ENODATA:
                                raise e
 
@@ -77,7 +77,7 @@ class database(fs_template.FsBased):
        def __has_cache(self,path):
                try:
                        self.__get(path,'_mtime_')
-               except NoValueException,e:
+               except NoValueException as e:
                        return False
 
                return True
@@ -85,7 +85,7 @@ class database(fs_template.FsBased):
        def __get(self,path,key,default=None):
                try:
                        return xattr.get(path,key,namespace=self.ns)
-               except IOError,e:
+               except IOError as e:
                        if not default is None and ENODATA == e.errno:
                                return default
                        else:
index 259be4108b4dfbdad30eb3b9f4ca6c4c5ad51b9b..3f46df8b9e3b432b11a8aaea429d85ecd1f3ff7c 100644 (file)
@@ -43,7 +43,7 @@ class database(fs_template.FsBased):
                                return d
                        finally:
                                myf.close()
-               except (IOError, OSError), e:
+               except (IOError, OSError) as e:
                        if e.errno != errno.ENOENT:
                                raise cache_errors.CacheCorruption(cpv, e)
                        raise KeyError(cpv)
@@ -51,7 +51,7 @@ class database(fs_template.FsBased):
        def _parse_data(self, data, cpv):
                try:
                        d = dict(map(lambda x:x.rstrip("\n").split("=", 1), data))
-               except ValueError, e:
+               except ValueError as e:
                        # If a line is missing an "=", the split length is 1 instead of 2.
                        raise cache_errors.CacheCorruption(cpv, e)
                return d
@@ -65,7 +65,7 @@ class database(fs_template.FsBased):
                                encoding=_encodings['fs'], errors='strict'),
                                mode='w', encoding=_encodings['repo.content'],
                                errors='backslashreplace')
-               except (IOError, OSError), e:
+               except (IOError, OSError) as e:
                        if errno.ENOENT == e.errno:
                                try:
                                        self._ensure_dirs(cpv)
@@ -73,7 +73,7 @@ class database(fs_template.FsBased):
                                                encoding=_encodings['fs'], errors='strict'),
                                                mode='w', encoding=_encodings['repo.content'],
                                                errors='backslashreplace')
-                               except (OSError, IOError),e:
+                               except (OSError, IOError) as e:
                                        raise cache_errors.CacheCorruption(cpv, e)
                        else:
                                raise cache_errors.CacheCorruption(cpv, e)
@@ -93,7 +93,7 @@ class database(fs_template.FsBased):
                new_fp = os.path.join(self.location,cpv)
                try:
                        os.rename(fp, new_fp)
-               except (OSError, IOError), e:
+               except (OSError, IOError) as e:
                        os.remove(fp)
                        raise cache_errors.CacheCorruption(cpv, e)
 
@@ -102,7 +102,7 @@ class database(fs_template.FsBased):
 #              import pdb;pdb.set_trace()
                try:
                        os.remove(os.path.join(self.location,cpv))
-               except OSError, e:
+               except OSError as e:
                        if errno.ENOENT == e.errno:
                                raise KeyError(cpv)
                        else:
@@ -120,7 +120,7 @@ class database(fs_template.FsBased):
                while len(dirs):
                        try:
                                dir_list = os.listdir(dirs[0])
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
index 1d4dbd28f759983d5d84e7abc8112d76a683ab08..cfa3340cd2e838c32d075d94fa3e37757f333cdd 100644 (file)
@@ -38,14 +38,14 @@ class database(fs_template.FsBased):
                                errors='replace')
                        for k,v in zip(self.auxdbkey_order, myf):
                                d[k] = v.rstrip("\n")
-               except (OSError, IOError),e:
+               except (OSError, IOError) as e:
                        if errno.ENOENT == e.errno:
                                raise KeyError(cpv)
                        raise cache_errors.CacheCorruption(cpv, e)
 
                try:
                        d["_mtime_"] = long(os.fstat(myf.fileno()).st_mtime)
-               except OSError, e:      
+               except OSError as e:    
                        myf.close()
                        raise cache_errors.CacheCorruption(cpv, e)
                myf.close()
@@ -60,7 +60,7 @@ class database(fs_template.FsBased):
                                encoding=_encodings['fs'], errors='strict'),
                                mode='w', encoding=_encodings['repo.content'],
                                errors='backslashreplace')
-               except (OSError, IOError), e:
+               except (OSError, IOError) as e:
                        if errno.ENOENT == e.errno:
                                try:
                                        self._ensure_dirs(cpv)
@@ -68,7 +68,7 @@ class database(fs_template.FsBased):
                                                encoding=_encodings['fs'], errors='strict'),
                                                mode='w', encoding=_encodings['repo.content'],
                                                errors='backslashreplace')
-                               except (OSError, IOError),e:
+                               except (OSError, IOError) as e:
                                        raise cache_errors.CacheCorruption(cpv, e)
                        else:
                                raise cache_errors.CacheCorruption(cpv, e)
@@ -83,7 +83,7 @@ class database(fs_template.FsBased):
                new_fp = os.path.join(self._base,cpv)
                try:
                        os.rename(fp, new_fp)
-               except (OSError, IOError), e:
+               except (OSError, IOError) as e:
                        os.remove(fp)
                        raise cache_errors.CacheCorruption(cpv, e)
 
@@ -91,7 +91,7 @@ class database(fs_template.FsBased):
        def _delitem(self, cpv):
                try:
                        os.remove(os.path.join(self._base,cpv))
-               except OSError, e:
+               except OSError as e:
                        if errno.ENOENT == e.errno:
                                raise KeyError(cpv)
                        else:
index ff1227bdb1017d9a39df59afa667ff8396c71b61..8b35593c2d448485ca35ab0bf12427e6a3a207d6 100644 (file)
@@ -61,7 +61,7 @@ class database(flat_hash.database):
                                try:
                                        d["_eclasses_"] = self.ec.get_eclass_data(
                                                d["INHERITED"].split())
-                               except KeyError, e:
+                               except KeyError as e:
                                        # INHERITED contains a non-existent eclass.
                                        raise cache_errors.CacheCorruption(cpv, e)
                                del d["INHERITED"]
@@ -122,13 +122,13 @@ class database(flat_hash.database):
                try:
                        myf = open(_unicode_encode(fp,
                                encoding=_encodings['fs'], errors='strict'), 'wb')
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        if errno.ENOENT == e.errno:
                                try:
                                        self._ensure_dirs(cpv)
                                        myf = open(_unicode_encode(fp,
                                                encoding=_encodings['fs'], errors='strict'), 'wb')
-                               except EnvironmentError, e:
+                               except EnvironmentError as e:
                                        raise cache_errors.CacheCorruption(cpv, e)
                        else:
                                raise cache_errors.CacheCorruption(cpv, e)
@@ -141,7 +141,7 @@ class database(flat_hash.database):
 
                try:
                        os.rename(fp, new_fp)
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        try:
                                os.unlink(fp)
                        except EnvironmentError:
index a002d6c06ecf75f5dbb0fe124ee31dcc852e0693..a4580bdc7531a434914ba33d74d2f831e06abcc8 100644 (file)
@@ -74,7 +74,7 @@ class SQLDatabase(template.database):
                                        self.SCHEMA_PACKAGE_NAME)
                        try:
                                self.con.execute(self.SCHEMA_PACKAGE_CREATE)
-                       except  self._BaseError, e:
+                       except  self._BaseError as e:
                                raise cache_errors.InitializationError(self.__class__, e)
 
                if not self._table_exists(self.SCHEMA_VALUES_NAME):
@@ -83,7 +83,7 @@ class SQLDatabase(template.database):
                                        self.SCHEMA_VALUES_NAME)
                        try:
                                self.con.execute(self.SCHEMA_VALUES_CREATE)
-                       except  self._BaseError, e:
+                       except  self._BaseError as e:
                                raise cache_errors.InitializationError(self.__class__, e)
 
 
@@ -103,7 +103,7 @@ class SQLDatabase(template.database):
                        self.con.execute("SELECT key, value FROM %s NATURAL JOIN %s "
                        "WHERE label=%s AND cpv=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
                        self.label, self._sfilter(cpv)))
-               except self._BaseError, e:
+               except self._BaseError as e:
                        raise cache_errors.CacheCorruption(self, cpv, e)
 
                rows = self.con.fetchall()
@@ -126,7 +126,7 @@ class SQLDatabase(template.database):
                                (self.SCHEMA_PACKAGE_NAME, self.label, self._sfilter(cpv)))
                                if self.autocommits:
                                        self.commit()
-                       except self._BaseError, e:
+                       except self._BaseError as e:
                                raise cache_errors.CacheCorruption(self, cpv, e)
                        if self.con.rowcount <= 0:
                                raise KeyError(cpv)
@@ -148,7 +148,7 @@ class SQLDatabase(template.database):
                        # insert.
                        try:
                                pkgid = self._insert_cpv(cpv)
-                       except self._BaseError, e:
+                       except self._BaseError as e:
                                raise cache_errors.CacheCorruption(cpv, e)
 
                        # __getitem__ fills out missing values, 
@@ -162,7 +162,7 @@ class SQLDatabase(template.database):
                                try:
                                        self.con.executemany("INSERT INTO %s (pkgid, key, value) VALUES(\"%s\", %%(key)s, %%(value)s)" % \
                                        (self.SCHEMA_VALUES_NAME, str(pkgid)), db_values)
-                               except self._BaseError, e:
+                               except self._BaseError as e:
                                        raise cache_errors.CacheCorruption(cpv, e)
                        if self.autocommits:
                                self.commit()
@@ -210,13 +210,13 @@ class SQLDatabase(template.database):
                if not self.autocommits:
                        try:
                                self.commit()
-                       except self._BaseError, e:
+                       except self._BaseError as e:
                                raise cache_errors.GeneralCacheCorruption(e)
 
                try:
                        self.con.execute("SELECT cpv FROM %s WHERE label=%s AND cpv=%s" % \
                                (self.SCHEMA_PACKAGE_NAME, self.label, self._sfilter(cpv)))
-               except self._BaseError, e:
+               except self._BaseError as e:
                        raise cache_errors.GeneralCacheCorruption(e)
                return self.con.rowcount > 0
 
@@ -225,13 +225,13 @@ class SQLDatabase(template.database):
                if not self.autocommits:
                        try:
                                self.commit()
-                       except self._BaseError, e:
+                       except self._BaseError as e:
                                raise cache_errors.GeneralCacheCorruption(e)
 
                try:
                        self.con.execute("SELECT cpv FROM %s WHERE label=%s" % 
                                (self.SCHEMA_PACKAGE_NAME, self.label))
-               except self._BaseError, e:
+               except self._BaseError as e:
                        raise cache_errors.GeneralCacheCorruption(e)
 #              return [ row[0] for row in self.con.fetchall() ]
                for x in self.con.fetchall():
@@ -242,7 +242,7 @@ class SQLDatabase(template.database):
                        self.con.execute("SELECT cpv, key, value FROM %s NATURAL JOIN %s "
                        "WHERE label=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
                        self.label))
-               except self._BaseError, e:
+               except self._BaseError as e:
                        raise cache_errors.CacheCorruption(self, cpv, e)
                
                oldcpv = None
@@ -288,7 +288,7 @@ class SQLDatabase(template.database):
                try:
                        self.con.execute("SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % \
                                (self.label, query))
-               except self._BaseError, e:
+               except self._BaseError as e:
                        raise cache_errors.GeneralCacheCorruption(e)
 
                return [ row[0] for row in self.con.fetchall() ]
index d5f765459f6d05c4d138371f7a5d600244d96c2f..073ca2cd8117852965623fafa56e5a4d89779b74 100644 (file)
@@ -70,7 +70,7 @@ class database(fs_template.FsBased):
                                raise cache_errors.InitializationError(self.__class__, "can't ensure perms on %s" % self._dbpath)
                        self._db_init_cache_size(config["cache_bytes"])
                        self._db_init_synchronous(config["synchronous"])
-               except self._db_error, e:
+               except self._db_error as e:
                        raise cache_errors.InitializationError(self.__class__, e)
 
        def _db_init_structures(self):
@@ -189,7 +189,7 @@ class database(fs_template.FsBased):
                try:
                        s = " ".join(update_statement)
                        cursor.execute(s)
-               except self._db_error, e:
+               except self._db_error as e:
                        writemsg("%s: %s\n" % (cpv, str(e)))
                        raise
 
index 97adb10588af6be187a08699aed671ad2992398c..d4573c760ecfa89e7ab76d9dec38066e783c2a5e 100644 (file)
@@ -173,7 +173,7 @@ class database(object):
                                        restricts[key] = re.compile(match).match
                                else:
                                        restricts[key] = re.compile(match[0],match[1]).match
-                       except re.error, e:
+                       except re.error as e:
                                raise InvalidRestriction(key, match, e)
                        if key not in self.__known_keys:
                                raise InvalidRestriction(key, match, "Key isn't valid")
index 57d328ced6eaa32454c128a49a6f05cb48892814..7b2f1026a90103ba53e19f83f109bb7d06fc7848 100644 (file)
@@ -33,11 +33,11 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
                dead_nodes.discard(x)
                try:
                        entry = src_cache[x]
-               except KeyError, e:
+               except KeyError as e:
                        noise.missing_entry(x)
                        del e
                        continue
-               except cache_errors.CacheError, ce:
+               except cache_errors.CacheError as ce:
                        noise.exception(x, ce)
                        del ce
                        continue
@@ -82,7 +82,7 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
                        try:
                                inherited = entry.get("INHERITED", "")
                                eclasses = entry.get("_eclasses_")
-                       except cache_errors.CacheError, ce:
+                       except cache_errors.CacheError as ce:
                                noise.exception(x, ce)
                                del ce
                                continue
@@ -123,7 +123,7 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
                        # been updated/translated (if needs be, for metadata/cache mainly)
                        try:
                                trg_cache[x] = entry
-                       except cache_errors.CacheError, ce:
+                       except cache_errors.CacheError as ce:
                                noise.exception(x, ce)
                                del ce
                                continue
@@ -141,7 +141,7 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
                        del trg_cache[key]
                except KeyError:
                        pass
-               except cache_errors.CacheError, ce:
+               except cache_errors.CacheError as ce:
                        noise.exception(ce)
                        del ce
        noise.finish()
index 0a67d2dc0caa0943ad91cf74bfbc0336a01f1113..7b1340dadb48da899ff595485f1f53e00b01c047 100644 (file)
@@ -67,7 +67,7 @@ try:
        from Crypto.Hash import SHA256, RIPEMD
        sha256hash = _generate_hash_function("SHA256", SHA256.new, origin="pycrypto")
        rmd160hash = _generate_hash_function("RMD160", RIPEMD.new, origin="pycrypto")
-except ImportError, e:
+except ImportError as e:
        pass
 
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
@@ -86,7 +86,7 @@ try:
                def rmd160():
                        return hashlib.new('ripemd160')
                rmd160hash = _generate_hash_function("RMD160", rmd160, origin="hashlib")
-except ImportError, e:
+except ImportError as e:
        pass
        
 
@@ -163,7 +163,7 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
                mysize = os.stat(filename)[stat.ST_SIZE]
                if mydict["size"] != mysize:
                        return False,(_("Filesize does not match recorded size"), mysize, mydict["size"])
-       except OSError, e:
+       except OSError as e:
                if e.errno == errno.ENOENT:
                        raise portage.exception.FileNotFound(filename)
                return False, (str(e), None, None)
@@ -244,7 +244,7 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
                                raise portage.exception.DigestException(hashname + \
                                        " hash function not available (needs dev-python/pycrypto)")
                        myhash, mysize = hashfunc_map[hashname](myfilename)
-               except (OSError, IOError), e:
+               except (OSError, IOError) as e:
                        if e.errno == errno.ENOENT:
                                raise portage.exception.FileNotFound(myfilename)
                        raise
@@ -253,7 +253,7 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
                if prelink_tmpfile:
                        try:
                                os.unlink(prelink_tmpfile)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
index 0fd2a54c5d2b1ac844db9887578ad607ddb76c08..c3f5d3045d531389d802a99dbbe4b58af21c9ad6 100644 (file)
@@ -206,7 +206,7 @@ def getentries(mydir,recursive=0):
                        mode='r', encoding=_encodings['content'], errors='strict')
                mylines=myfile.readlines()
                myfile.close()
-       except SystemExit, e:
+       except SystemExit as e:
                raise
        except:
                mylines=[]
@@ -296,9 +296,9 @@ def getentries(mydir,recursive=0):
                                        print "stat done"
                                
                                del mystat
-                       except SystemExit, e:
+                       except SystemExit as e:
                                raise
-                       except Exception, e:
+                       except Exception as e:
                                print "failed to stat",file
                                print e
                                return
index d15953735e17fd11f45982dd6f62589b3cc22f8f..3c96a375afec108b08edc3463c57a897d327468c 100644 (file)
@@ -309,7 +309,7 @@ class binarytree(object):
                        os.unlink(mylink)
                try:
                        os.rmdir(os.path.join(self.pkgdir, mycat))
-               except OSError, e:
+               except OSError as e:
                        if e.errno not in (errno.ENOENT,
                                errno.ENOTEMPTY, errno.EEXIST):
                                raise
@@ -324,7 +324,7 @@ class binarytree(object):
                self._ensure_dir(os.path.dirname(full_path))
                try:
                        os.unlink(full_path)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ENOENT:
                                raise
                        del e
@@ -408,7 +408,7 @@ class binarytree(object):
                src_path = os.path.join(self.pkgdir, mycat, myfile)
                try:
                        mystat = os.lstat(src_path)
-               except OSError, e:
+               except OSError as e:
                        mystat = None
                if mystat and stat.S_ISREG(mystat.st_mode):
                        self._ensure_dir(os.path.join(self.pkgdir, "All"))
@@ -674,7 +674,7 @@ class binarytree(object):
                                        pkgindex.read(f)
                                finally:
                                        f.close()
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                        local_timestamp = pkgindex.header.get("TIMESTAMP", None)
@@ -702,7 +702,7 @@ class binarytree(object):
                                                        pkgindex = rmt_idx
                                finally:
                                        f.close()
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                writemsg(_("\n\n!!! Error fetching binhost package" \
                                        " info from '%s'\n") % base_url)
                                writemsg("!!! %s\n\n" % str(e))
@@ -807,7 +807,7 @@ class binarytree(object):
                                                remote_metadata[k] = v.strip()
                                        self._remotepkgs[fullpkg] = remote_metadata
                                        #print "  -- Injected"
-                               except SystemExit, e:
+                               except SystemExit as e:
                                        raise
                                except:
                                        writemsg(_("!!! Failed to inject remote binary package: %s\n") % fullpkg,
@@ -835,7 +835,7 @@ class binarytree(object):
                        full_path = filename
                try:
                        s = os.stat(full_path)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ENOENT:
                                raise
                        del e
@@ -1001,7 +1001,7 @@ class binarytree(object):
                                deps = use_reduce(deps, uselist=raw_use)
                                deps = paren_normalize(deps)
                                deps = paren_enclose(deps)
-                       except portage.exception.InvalidDependString, e:
+                       except portage.exception.InvalidDependString as e:
                                writemsg("%s: %s\n" % (k, str(e)),
                                        noiselevel=-1)
                                raise
@@ -1181,8 +1181,8 @@ class binarytree(object):
                myslot = ""
                try:
                        myslot = self.dbapi.aux_get(mycatpkg,["SLOT"])[0]
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
-               except Exception, e:
+               except Exception as e:
                        pass
                return myslot
index 4cc07362ad48b89abebc2d66431d6e85dbc99e12..7d37f365f19bf77c00c75e927b9473cd8c0e6cd0 100644 (file)
@@ -388,7 +388,7 @@ class portdbapi(dbapi):
                try:
                        ensure_dirs(self.depcachedir, gid=portage_gid,
                                mode=dirmode, mask=modemask)
-               except PortageException, e:
+               except PortageException as e:
                        pass
 
        def close_caches(self):
@@ -789,7 +789,7 @@ class portdbapi(dbapi):
                        mystat = None
                        try:
                                mystat = os.stat(file_path)
-                       except OSError, e:
+                       except OSError as e:
                                pass
                        if mystat is None:
                                existing_size = 0
@@ -825,7 +825,7 @@ class portdbapi(dbapi):
                                try:
                                        ok, reason = portage.checksum.verify_all(
                                                os.path.join(self.mysettings["DISTDIR"], x), mysums[x])
-                               except FileNotFound, e:
+                               except FileNotFound as e:
                                        ok = False
                                        reason = _("File Not Found: '%s'") % (e,)
                        if not ok:
@@ -1098,7 +1098,7 @@ class portdbapi(dbapi):
                                metadata.update(izip(aux_keys, self.aux_get(mycpv, aux_keys)))
                        except KeyError:
                                continue
-                       except PortageException, e:
+                       except PortageException as e:
                                writemsg("!!! Error: aux_get('%s', %s)\n" % (mycpv, aux_keys),
                                        noiselevel=-1)
                                writemsg("!!! %s\n" % (e,), noiselevel=-1)
@@ -1213,8 +1213,8 @@ class portagetree(object):
                myslot = ""
                try:
                        myslot = self.dbapi.aux_get(mycatpkg, ["SLOT"])[0]
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
-               except Exception, e:
+               except Exception as e:
                        pass
                return myslot
index 284d5ff1f55c1567396dadc1b46b56cebe3c08ac..45686ee00f4ae69f17b66226fe4d103c6900e936 100644 (file)
@@ -80,10 +80,10 @@ class PreservedLibsRegistry(object):
                        self._data = pickle.load(
                                open(_unicode_encode(self._filename,
                                        encoding=_encodings['fs'], errors='strict'), 'rb'))
-               except (ValueError, pickle.UnpicklingError), e:
+               except (ValueError, pickle.UnpicklingError) as e:
                        writemsg_level(_("!!! Error loading '%s': %s\n") % \
                                (self._filename, e), level=logging.ERROR, noiselevel=-1)
-               except (EOFError, IOError), e:
+               except (EOFError, IOError) as e:
                        if isinstance(e, EOFError) or e.errno == errno.ENOENT:
                                pass
                        elif e.errno == PermissionDenied.errno:
@@ -104,7 +104,7 @@ class PreservedLibsRegistry(object):
                        f = atomic_ofstream(self._filename, 'wb')
                        pickle.dump(self._data, f, protocol=2)
                        f.close()
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        if e.errno != PermissionDenied.errno:
                                writemsg("!!! %s %s\n" % (e, self._filename), noiselevel=-1)
                else:
@@ -335,7 +335,7 @@ class LinkageMap(object):
                                        for x in items)
                        try:
                                proc = subprocess.Popen(args, stdout=subprocess.PIPE)
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                raise CommandNotFound(args[0])
@@ -907,7 +907,7 @@ class vardbapi(dbapi):
                                try:
                                        os.rename(os.path.join(newpath, old_pf + ".ebuild"),
                                                os.path.join(newpath, new_pf + ".ebuild"))
-                               except EnvironmentError, e:
+                               except EnvironmentError as e:
                                        if e.errno != errno.ENOENT:
                                                raise
                                        del e
@@ -931,7 +931,7 @@ class vardbapi(dbapi):
                cat_dir = self.getpath(mysplit[0])
                try:
                        dir_list = os.listdir(cat_dir)
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        if e.errno == PermissionDenied.errno:
                                raise PermissionDenied(cat_dir)
                        del e
@@ -972,7 +972,7 @@ class vardbapi(dbapi):
                                try:
                                        return [x for x in os.listdir(p) \
                                                if os.path.isdir(os.path.join(p, x))]
-                               except EnvironmentError, e:
+                               except EnvironmentError as e:
                                        if e.errno == PermissionDenied.errno:
                                                raise PermissionDenied(p)
                                        del e
@@ -1097,7 +1097,7 @@ class vardbapi(dbapi):
                                f.close()
                                apply_secpass_permissions(
                                        self._aux_cache_filename, gid=portage_gid, mode=0644)
-                       except (IOError, OSError), e:
+                       except (IOError, OSError) as e:
                                pass
                        self._aux_cache["modified"] = set()
 
@@ -1129,7 +1129,7 @@ class vardbapi(dbapi):
                        aux_cache = mypickle.load()
                        f.close()
                        del f
-               except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError), e:
+               except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e:
                        if isinstance(e, pickle.UnpicklingError):
                                writemsg(_("!!! Error loading '%s': %s\n") % \
                                        (self._aux_cache_filename, str(e)), noiselevel=-1)
@@ -1193,7 +1193,7 @@ class vardbapi(dbapi):
                mydir_stat = None
                try:
                        mydir_stat = os.stat(mydir)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ENOENT:
                                raise
                        raise KeyError(mycpv)
@@ -1251,7 +1251,7 @@ class vardbapi(dbapi):
                if st is None:
                        try:
                                st = os.stat(mydir)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno == errno.ENOENT:
                                        raise KeyError(mycpv)
                                elif e.errno == PermissionDenied.errno:
@@ -1343,7 +1343,7 @@ class vardbapi(dbapi):
                                encoding=_encodings['fs'], errors='strict'),
                                mode='r', encoding=_encodings['repo.content'],
                                errors='replace')
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        new_vdb = not bool(self.cpv_all())
                        if not new_vdb:
                                writemsg(_("!!! Unable to read COUNTER file: '%s'\n") % \
@@ -1356,7 +1356,7 @@ class vardbapi(dbapi):
                                        counter = long(cfile.readline().strip())
                                finally:
                                        cfile.close()
-                       except (OverflowError, ValueError), e:
+                       except (OverflowError, ValueError) as e:
                                writemsg(_("!!! COUNTER file is corrupt: '%s'\n") % \
                                        self._counter_path, noiselevel=-1)
                                writemsg("!!! %s\n" % str(e), noiselevel=-1)
@@ -1674,9 +1674,9 @@ class vartree(object):
                                                mys = myprovide.split("/")
                                        myprovides += [mys[0] + "/" + mys[1]]
                        return myprovides
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
-               except Exception, e:
+               except Exception as e:
                        mydir = os.path.join(self.root, VDB_PATH, mycpv)
                        writemsg(_("\nParse Error reading PROVIDE and USE in '%s'\n") % mydir,
                                noiselevel=-1)
@@ -1931,7 +1931,7 @@ class dblink(object):
                                encoding=_encodings['fs'], errors='strict'),
                                mode='r', encoding=_encodings['repo.content'],
                                errors='replace')
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        if e.errno != errno.ENOENT:
                                raise
                        del e
@@ -2089,7 +2089,7 @@ class dblink(object):
                        try:
                                doebuild_environment(myebuildpath, "prerm", self.myroot,
                                        self.settings, 0, 0, self.vartree.dbapi)
-                       except UnsupportedAPIException, e:
+                       except UnsupportedAPIException as e:
                                # Sometimes this happens due to corruption of the EAPI file.
                                writemsg(_("!!! FAILED prerm: %s\n") % \
                                        os.path.join(self.dbdir, "EAPI"), noiselevel=-1)
@@ -2249,7 +2249,7 @@ class dblink(object):
                                if catdir_lock:
                                        try:
                                                os.rmdir(catdir)
-                                       except OSError, e:
+                                       except OSError as e:
                                                if e.errno not in (errno.ENOENT,
                                                        errno.ENOTEMPTY, errno.EEXIST):
                                                        raise
@@ -2468,7 +2468,7 @@ class dblink(object):
                                        not self.isprotected(obj):
                                        try:
                                                unlink(obj, lstatobj)
-                                       except EnvironmentError, e:
+                                       except EnvironmentError as e:
                                                if e.errno not in ignored_unlink_errnos:
                                                        raise
                                                del e
@@ -2499,7 +2499,7 @@ class dblink(object):
                                        try:
                                                unlink(obj, lstatobj)
                                                show_unmerge("<<<", "", file_type, obj)
-                                       except (OSError, IOError),e:
+                                       except (OSError, IOError) as e:
                                                if e.errno not in ignored_unlink_errnos:
                                                        raise
                                                del e
@@ -2511,7 +2511,7 @@ class dblink(object):
                                        mymd5 = None
                                        try:
                                                mymd5 = perf_md5(obj, calc_prelink=1)
-                                       except FileNotFound, e:
+                                       except FileNotFound as e:
                                                # the file has disappeared between now and our stat call
                                                show_unmerge("---", unmerge_desc["!obj"], file_type, obj)
                                                continue
@@ -2523,7 +2523,7 @@ class dblink(object):
                                                continue
                                        try:
                                                unlink(obj, lstatobj)
-                                       except (OSError, IOError), e:
+                                       except (OSError, IOError) as e:
                                                if e.errno not in ignored_unlink_errnos:
                                                        raise
                                                del e
@@ -2558,7 +2558,7 @@ class dblink(object):
                                                        # Restore the parent flags we saved before unlinking
                                                        bsd_chflags.chflags(parent_name, pflags)
                                        show_unmerge("<<<", "", "dir", obj)
-                               except EnvironmentError, e:
+                               except EnvironmentError as e:
                                        if e.errno not in ignored_rmdir_errnos:
                                                raise
                                        if e.errno != errno.ENOENT:
@@ -2678,7 +2678,7 @@ class dblink(object):
                        parent_path = os_filename_arg.path.dirname(destfile)
                        try:
                                parent_stat = os_filename_arg.stat(parent_path)
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -2742,7 +2742,7 @@ class dblink(object):
                        return
                try:
                        self.vartree.dbapi.linkmap.rebuild(**kwargs)
-               except CommandNotFound, e:
+               except CommandNotFound as e:
                        self._linkmap_broken = True
                        self._display_merge(_("!!! Disabling preserve-libs " \
                                "due to error: Command Not Found: %s\n") % (e,),
@@ -3038,7 +3038,7 @@ class dblink(object):
                                obj_type = _("obj")
                        try:
                                os.unlink(obj)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -3101,7 +3101,7 @@ class dblink(object):
                                        os.path.join(destroot, f.lstrip(os.path.sep)))
                                try:
                                        dest_lstat = os.lstat(dest_path)
-                               except EnvironmentError, e:
+                               except EnvironmentError as e:
                                        if e.errno == errno.ENOENT:
                                                del e
                                                continue
@@ -3116,7 +3116,7 @@ class dblink(object):
                                                        try:
                                                                dest_lstat = os.lstat(parent_path)
                                                                break
-                                                       except EnvironmentError, e:
+                                                       except EnvironmentError as e:
                                                                if e.errno != errno.ENOTDIR:
                                                                        raise
                                                                del e
@@ -3185,7 +3185,7 @@ class dblink(object):
                        path = os.path.join(root, f.lstrip(os.sep))
                        try:
                                st = os.lstat(path)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno not in (errno.ENOENT, errno.ENOTDIR):
                                        raise
                                del e
@@ -3236,7 +3236,7 @@ class dblink(object):
 
                        try:
                                s = os.lstat(path)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno not in (errno.ENOENT, errno.ENOTDIR):
                                        raise
                                del e
@@ -3360,7 +3360,7 @@ class dblink(object):
                                        encoding=_encodings['fs'], errors='strict'),
                                        mode='r', encoding=_encodings['repo.content'],
                                        errors='replace').readline().strip()
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -3669,7 +3669,7 @@ class dblink(object):
                try:
                        os.unlink(os.path.join(
                                os.path.dirname(normalize_path(srcroot)), ".installed"))
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ENOENT:
                                raise
                        del e
@@ -4006,7 +4006,7 @@ class dblink(object):
                        try:
                                mydstat = os.lstat(mydest)
                                mydmode = mydstat.st_mode
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -4420,7 +4420,7 @@ def tar_contents(contents, root, tar, protect=None, onProgress=None):
                curval += 1
                try:
                        lst = os.lstat(path)
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ENOENT:
                                raise
                        del e
index 49e53c2ee0a77aa2660eda734721f3bb84b19377..e9b220a397512b9cc3a87e205f2a7ab1510f4a6b 100644 (file)
@@ -64,7 +64,7 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
 
     try:
         shutil.copy2(curconf, archive)
-    except(IOError, os.error), why:
+    except(IOError, os.error) as why:
         print >> sys.stderr, _('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
               {"curconf": curconf, "archive": archive, "reason": str(why)}
     if os.path.exists(archive + ',v'):
@@ -80,7 +80,7 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
 
         try:
             shutil.copy2(newconf, archive)
-        except(IOError, os.error), why:
+        except(IOError, os.error) as why:
             print >> sys.stderr, _('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
                   {"newconf": newconf, "archive": archive, "reason": str(why)}
 
@@ -123,7 +123,7 @@ def file_archive(archive, curconf, newconf, mrgconf):
 
     try:
         shutil.copy2(curconf, archive)
-    except(IOError, os.error), why:
+    except(IOError, os.error) as why:
         print >> sys.stderr, _('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
               {"curconf": curconf, "archive": archive, "reason": str(why)}
 
@@ -131,7 +131,7 @@ def file_archive(archive, curconf, newconf, mrgconf):
         # Save off new config file in the archive dir with .dist.new suffix
         try:
             shutil.copy2(newconf, archive + '.dist.new')
-        except(IOError, os.error), why:
+        except(IOError, os.error) as why:
             print >> sys.stderr, _('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
                   {"newconf": newconf, "archive": archive + '.dist.new', "reason": str(why)}
 
index 3f86a6d695b5f47ff57b99210982577ff59c3449..e0b9383c536317937f7fd5e9a2d0e7c3c4f89ced 100644 (file)
@@ -80,7 +80,7 @@ class cache(object):
                for x in [normalize_path(os.path.join(y,"eclass")) for y in self.porttrees]:
                        try:
                                eclass_filenames = os.listdir(x)
-                       except OSError, e:
+                       except OSError as e:
                                if e.errno in ignored_listdir_errnos:
                                        del e
                                        continue
index 7bd567ceecc435eacaf23d72f2d46f42671b45d6..c689d821d28ee1cab42716cf192736fdf1745a91 100644 (file)
@@ -168,10 +168,10 @@ def elog_process(cpv, mysettings, phasefilter=None):
                                if hasattr(m, "finalize") and not m.finalize in _elog_atexit_handlers:
                                        _elog_atexit_handlers.append(m.finalize)
                                        atexit_register(m.finalize)
-                       except (ImportError, AttributeError), e:
+                       except (ImportError, AttributeError) as e:
                                writemsg(_("!!! Error while importing logging modules "
                                        "while loading \"mod_%s\":\n") % str(s))
                                writemsg("%s\n" % str(e), noiselevel=-1)
-                       except PortageException, e:
+                       except PortageException as e:
                                writemsg("%s\n" % str(e), noiselevel=-1)
 
index 841986b96ddd8fa47b20b6431f9c8e4461f26318..ac96f3b200a666b182eee8ea4995591407a0535d 100644 (file)
@@ -38,7 +38,7 @@ def process(mysettings, key, logentries, fulltext):
        mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, fulltext)
        try:
                portage.mail.send_mail(mysettings, mymessage)
-       except PortageException, e:
+       except PortageException as e:
                writemsg("%s\n" % str(e), noiselevel=-1)
 
        return
index e642dc044726203f4a4ccecbdc7c162c1aa1e851..4380146d2d4dcd4acbed62b5ed70e36cc7d93e67 100644 (file)
@@ -73,7 +73,7 @@ def _finalize(mysettings, items):
                        portage.mail.send_mail(mysettings, mymessage)
                finally:
                        signal.alarm(0)
-       except PortageException, e:
+       except PortageException as e:
                writemsg("%s\n" % str(e), noiselevel=-1)
 
        return
index 5ec3a066fb52536fe0ff9ef2dba1c60de4509b3b..60e0e1b11ede3f66b4243f15e77abf9d5320c341 100644 (file)
@@ -153,7 +153,7 @@ class FileLoader(DataLoader):
                                f = codecs.open(_unicode_encode(fn,
                                        encoding=_encodings['fs'], errors='strict'), mode='r',
                                        encoding=_encodings['content'], errors='replace')
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno not in (errno.ENOENT, errno.ESTALE):
                                        raise
                                del e
index dfe2fad59c76bea77d53acb18a28363e7fba189b..adab28fabc0008886dd5393d78fb3b7d216a9fb6 100644 (file)
@@ -26,12 +26,12 @@ except ImportError:
 
 try:
        import ftplib
-except ImportError, e:
+except ImportError as e:
        sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT FTPLIB: ")+str(e)+"\n")
 
 try:
        import httplib
-except ImportError, e:
+except ImportError as e:
        sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT HTTPLIB: ")+str(e)+"\n")
 
 def make_metadata_dict(data):
@@ -207,7 +207,7 @@ def make_ftp_request(conn, address, rest=None, dest=None):
 
                return mydata,not (fsize==data_size),""
 
-       except ValueError, e:
+       except ValueError as e:
                return None,int(str(e)[:4]),str(e)
        
 
@@ -223,9 +223,9 @@ def make_http_request(conn, address, params={}, headers={}, dest=None):
                        if (rc != 0):
                                conn,ignore,ignore,ignore,ignore = create_conn(address)
                        conn.request("GET", address, params, headers)
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
-               except Exception, e:
+               except Exception as e:
                        return None,None,"Server request failed: "+str(e)
                response = conn.getresponse()
                rc = response.status
@@ -481,7 +481,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
 
        try:
                conn, protocol, address, params, headers = create_conn(baseurl, conn)
-       except socket.error, e:
+       except socket.error as e:
                # ftplib.FTP(host) can raise errors like this:
                #   socket.error: (111, 'Connection refused')
                sys.stderr.write("!!! %s\n" % (e,))
@@ -522,7 +522,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        import portage.exception
        try:
                filelist = dir_get_list(baseurl, conn)
-       except portage.exception.PortageException, e:
+       except portage.exception.PortageException as e:
                sys.stderr.write(_("!!! Error connecting to '%s'.\n") % baseurl)
                sys.stderr.write("!!! %s\n" % str(e))
                del e
@@ -547,7 +547,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                                        if mytempfile.tell() > len(data):
                                                mytempfile.seek(0)
                                                data = mytempfile.read()
-                               except ValueError, e:
+                               except ValueError as e:
                                        sys.stderr.write("--- "+str(e)+"\n")
                                        if trynum < 3:
                                                sys.stderr.write(_("Retrying...\n"))
@@ -562,9 +562,9 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                                                mytempfile.seek(0)
                                                gzindex = gzip.GzipFile(mfile[:-3],'rb',9,mytempfile)
                                                data = gzindex.read()
-                                       except SystemExit, e:
+                                       except SystemExit as e:
                                                raise
-                                       except Exception, e:
+                                       except Exception as e:
                                                mytempfile.close()
                                                sys.stderr.write(_("!!! Failed to use gzip: ")+str(e)+"\n")
                                                sys.stderr.flush()
@@ -578,9 +578,9 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                                        out.write(_("Pickle loaded.\n"))
                                        out.flush()
                                        break
-                               except SystemExit, e:
+                               except SystemExit as e:
                                        raise
-                               except Exception, e:
+                               except Exception as e:
                                        sys.stderr.write(_("!!! Failed to read data from index: ")+str(mfile)+"\n")
                                        sys.stderr.write("!!! "+str(e)+"\n")
                                        sys.stderr.flush()
@@ -589,9 +589,9 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                                        encoding=_encodings['fs'], errors='strict'), 'wb')
                                pickle.dump(metadata, metadatafile, protocol=2)
                                metadatafile.close()
-                       except SystemExit, e:
+                       except SystemExit as e:
                                raise
-                       except Exception, e:
+                       except Exception as e:
                                sys.stderr.write(_("!!! Failed to write binary metadata to disk!\n"))
                                sys.stderr.write("!!! "+str(e)+"\n")
                                sys.stderr.flush()
@@ -687,9 +687,9 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                                encoding=_encodings['fs'], errors='strict'), 'wb')
                        pickle.dump(metadata[baseurl]["data"], metadatafile, protocol=2)
                        metadatafile.close()
-       except SystemExit, e:
+       except SystemExit as e:
                raise
-       except Exception, e:
+       except Exception as e:
                sys.stderr.write(_("!!! Failed to write binary metadata to disk!\n"))
                sys.stderr.write("!!! "+str(e)+"\n")
                sys.stderr.flush()
index adf82af811e01a6db4c61e72a22a95123947592a..f2147c5e1d87ace072cf524cc77407908b6c7072 100644 (file)
@@ -65,7 +65,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
                try:
                        try:
                                myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR, 0660)
-                       except OSError, e:
+                       except OSError as e:
                                func_call = "open('%s')" % lockfilename
                                if e.errno == OperationNotPermitted.errno:
                                        raise OperationNotPermitted(func_call)
@@ -78,7 +78,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
                                try:
                                        if os.stat(lockfilename).st_gid != portage_gid:
                                                os.chown(lockfilename, -1, portage_gid)
-                               except OSError, e:
+                               except OSError as e:
                                        if e.errno in (errno.ENOENT, errno.ESTALE):
                                                return lockfile(mypath,
                                                        wantnewlockfile=wantnewlockfile,
@@ -103,7 +103,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
        locking_method = fcntl.lockf
        try:
                fcntl.lockf(myfd,fcntl.LOCK_EX|fcntl.LOCK_NB)
-       except IOError, e:
+       except IOError as e:
                if "errno" not in dir(e):
                        raise
                if e.errno in (errno.EACCES, errno.EAGAIN):
@@ -123,7 +123,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
                        # try for the exclusive lock now.
                        try:
                                fcntl.lockf(myfd, fcntl.LOCK_EX)
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                out.eend(1, str(e))
                                raise
                        out.eend(os.EX_OK)
@@ -168,7 +168,7 @@ def _fstat_nlink(fd):
        """
        try:
                return os.fstat(fd).st_nlink
-       except EnvironmentError, e:
+       except EnvironmentError as e:
                if e.errno in (errno.ENOENT, errno.ESTALE):
                        # Some filesystems such as CIFS return
                        # ENOENT which means st_nlink == 0.
@@ -229,7 +229,7 @@ def unlockfile(mytuple):
                                writemsg(_("lockfile does not exist '%s'\n") % lockfilename, 1)
                                os.close(myfd)
                                return False
-       except Exception, e:
+       except Exception as e:
                writemsg(_("Failed to get lock... someone took it.\n"), 1)
                writemsg(str(e)+"\n",1)
 
index 26045573926a0b4aa11bd647da0b3569aad4d924..a8b3849696ae07d093392ba232e118bde1df0e13 100644 (file)
@@ -126,9 +126,9 @@ def send_mail(mysettings, message):
                                myconn.login(mymailuser, mymailpasswd)
                        myconn.sendmail(myfrom, myrecipient, message.as_string())
                        myconn.quit()
-               except smtplib.SMTPException, e:
+               except smtplib.SMTPException as e:
                        raise portage.exception.PortageException(_("!!! An error occured while trying to send logmail:\n")+str(e))
-               except socket.error, e:
+               except socket.error as e:
                        raise portage.exception.PortageException(_("!!! A network error occured while trying to send logmail:\n%s\nSure you configured PORTAGE_ELOG_MAILURI correctly?") % str(e))
        return
        
index 25893d759cdfe2cad3a692a7b19aa45391a7f499..e60850e5f501ea5d254ec069e67c5713a761eeea 100644 (file)
@@ -151,7 +151,7 @@ class Manifest(object):
                        self._parseDigests(fd, myhashdict=myhashdict, **kwargs)
                        fd.close()
                        return myhashdict
-               except (OSError, IOError), e:
+               except (OSError, IOError) as e:
                        if e.errno == errno.ENOENT:
                                raise FileNotFound(file_path)
                        else:
@@ -243,7 +243,7 @@ class Manifest(object):
                                                        if oldentries[i] != myentries[i]:
                                                                update_manifest = True
                                                                break
-                               except (IOError, OSError), e:
+                               except (IOError, OSError) as e:
                                        if e.errno == errno.ENOENT:
                                                pass
                                        else:
@@ -253,7 +253,7 @@ class Manifest(object):
                                        "".join("%s\n" % str(myentry) for myentry in myentries))
                        if sign:
                                self.sign()
-               except (IOError, OSError), e:
+               except (IOError, OSError) as e:
                        if e.errno == errno.EACCES:
                                raise PermissionDenied(str(e))
                        raise
@@ -435,7 +435,7 @@ class Manifest(object):
                        if not ok:
                                raise DigestException(tuple([self._getAbsname(ftype, fname)]+list(reason)))
                        return ok, reason
-               except FileNotFound, e:
+               except FileNotFound as e:
                        if not ignoreMissing:
                                raise
                        return False, _("File Not Found: '%s'") % str(e)
index baf818f58d58b6d0c4343bc52e67e0b92c4976fd..06073df71977f19d21c9f861fe6deb6b30e7aa0c 100644 (file)
@@ -218,7 +218,7 @@ def _parse_color_map(config_root='/', onerror=None):
                                        _styles[k] = tuple(code_list)
                                elif k in codes:
                                        codes[k] = "".join(code_list)
-       except (IOError, OSError), e:
+       except (IOError, OSError) as e:
                if e.errno == errno.ENOENT:
                        raise FileNotFound(myfile)
                elif e.errno == errno.EACCES:
@@ -745,10 +745,10 @@ def _init(config_root='/'):
                        onerror=lambda e: writemsg("%s\n" % str(e), noiselevel=-1))
        except FileNotFound:
                pass
-       except PermissionDenied, e:
+       except PermissionDenied as e:
                writemsg(_("Permission denied: '%s'\n") % str(e), noiselevel=-1)
                del e
-       except PortageException, e:
+       except PortageException as e:
                writemsg("%s\n" % str(e), noiselevel=-1)
                del e
 
index 1822a3082ef25931c840f22281b29be85e038ed2..9698743f81fb54bdfe6ade9044b304a7f74f8546 100644 (file)
@@ -239,7 +239,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
                try:
                        _exec(binary, mycommand, opt_name, fd_pipes,
                              env, gid, groups, uid, umask, pre_exec)
-               except Exception, e:
+               except Exception as e:
                        # We need to catch _any_ exception so that it doesn't
                        # propogate out of this function and cause exiting
                        # with anything other than os._exit()
index f52c7fa1abb9ba71bf08d82ffad1b8e113e8cebb..3b8084ab3cb53d29a07fdca4dc990ed6eb3e11b8 100644 (file)
@@ -97,7 +97,7 @@ class SetConfig(object):
                                        newsets = {}
                                        try:
                                                newsets = setclass.multiBuilder(optdict, self.settings, self.trees)
-                                       except SetConfigError, e:
+                                       except SetConfigError as e:
                                                self.errors.append(_("Configuration error in section '%s': %s") % (sname, str(e)))
                                                continue
                                        for x in newsets:
@@ -126,7 +126,7 @@ class SetConfig(object):
                                                if parser.has_option(sname, "world-candidate") and \
                                                        not parser.getboolean(sname, "world-candidate"):
                                                        self.psets[setname].world_candidate = False
-                                       except SetConfigError, e:
+                                       except SetConfigError as e:
                                                self.errors.append(_("Configuration error in section '%s': %s") % (sname, str(e)))
                                                continue
                                else:
index 5cd6c6ba1adbea6ff2c536f1cdc0956a69657b68..06ebcadfd6cde3f065d2c470be1bcb0b28a9c074 100644 (file)
@@ -299,7 +299,7 @@ class AgeSet(EverythingSet):
                        raise SetConfigError(_("invalid 'mode' value %s (use either 'newer' or 'older')") % mode)
                try:
                        age = int(options.get("age", "7"))
-               except ValueError, e:
+               except ValueError as e:
                        raise SetConfigError(_("value of option 'age' is not an integer"))
                return AgeSet(vardb=trees["vartree"].dbapi, mode=mode, age=age)
 
index 13c8508e0ad191030be4a4f52a815c7cb2e4b394..b052a444df2628e863f00365d8c788bcc4541a61 100644 (file)
@@ -77,7 +77,7 @@ class StaticFileSet(EditablePackageSet):
                                for fname in errors:
                                        for e in errors[fname]:
                                                self.errors.append(fname+": "+e)
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -249,7 +249,7 @@ class WorldSet(EditablePackageSet):
                                for fname in errors:
                                        for e in errors[fname]:
                                                self.errors.append(fname+": "+e)
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
@@ -269,7 +269,7 @@ class WorldSet(EditablePackageSet):
                                for fname in errors:
                                        for e in errors[fname]:
                                                self.errors.append(fname+": "+e)
-                       except EnvironmentError, e:
+                       except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
index 97a5f42d0aa9385400b2e648cb329ad327dffcdb..8dfbddd784b4897cdbbd31616ba72bc4fcb56199 100644 (file)
@@ -46,7 +46,7 @@ class SpawnTestCase(TestCase):
                        if logfile:
                                try:
                                        os.unlink(logfile)
-                               except EnvironmentError, e:
+                               except EnvironmentError as e:
                                        if e.errno != errno.ENOENT:
                                                raise
                                        del e
index 251da88a432ea402158ef6a46be792c7f795f218..0941ba06b45846b09dff4e7e23b2cc163ebd3529 100644 (file)
@@ -94,7 +94,7 @@ def grab_updates(updpath, prev_mtimes=None):
        given then only updates with differing mtimes are considered."""
        try:
                mylist = os.listdir(updpath)
-       except OSError, oe:
+       except OSError as oe:
                if oe.errno == errno.ENOENT:
                        raise DirectoryNotFound(updpath)
                raise
@@ -256,7 +256,7 @@ def update_config_files(config_root, protect, protect_mask, update_iter):
                        updating_file = new_protect_filename(updating_file)
                try:
                        write_atomic(updating_file, "".join(file_contents[x]))
-               except PortageException, e:
+               except PortageException as e:
                        writemsg("\n!!! %s\n" % str(e), noiselevel=-1)
                        writemsg(_("!!! An error occured while updating a config file:") + \
                                " '%s'\n" % updating_file, noiselevel=-1)
index 04a7994667ff0246ea6baa0154652e71aff5f2f1..5cc3c5e5779a08d163424c6808b05c0556800fa9 100644 (file)
@@ -347,7 +347,7 @@ def grablines(myfilename,recursive=0):
                                mode='r', encoding=_encodings['content'], errors='replace')
                        mylines = myfile.readlines()
                        myfile.close()
-               except IOError, e:
+               except IOError as e:
                        if e.errno == PermissionDenied.errno:
                                raise PermissionDenied(myfilename)
                        pass
@@ -389,7 +389,7 @@ class _tolerant_shlex(shlex.shlex):
        def sourcehook(self, newfile):
                try:
                        return shlex.shlex.sourcehook(self, newfile)
-               except EnvironmentError, e:
+               except EnvironmentError as e:
                        writemsg(_("!!! Parse error in '%s': source command failed: %s\n") % \
                                (self.infile, str(e)), noiselevel=-1)
                        return (newfile, StringIO())
@@ -420,7 +420,7 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
                                encoding=_encodings['content'], errors='replace').read()
                if content and content[-1] != '\n':
                        content += '\n'
-       except IOError, e:
+       except IOError as e:
                if e.errno == PermissionDenied.errno:
                        raise PermissionDenied(mycfg)
                if e.errno != errno.ENOENT:
@@ -494,9 +494,9 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
                                expand_map[key] = mykeys[key]
                        else:
                                mykeys[key] = val
-       except SystemExit, e:
+       except SystemExit as e:
                raise
-       except Exception, e:
+       except Exception as e:
                raise portage.exception.ParseError(str(e)+" in "+mycfg)
        return mykeys
        
@@ -626,9 +626,9 @@ def pickle_read(filename,default=None,debug=0):
                myf.close()
                del mypickle,myf
                writemsg(_("pickle_read(): Loaded pickle. '")+filename+"'\n",1)
-       except SystemExit, e:
+       except SystemExit as e:
                raise
-       except Exception, e:
+       except Exception as e:
                writemsg(_("!!! Failed to load pickle: ")+str(e)+"\n",1)
                data = default
        return data
@@ -736,7 +736,7 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
                                stat_cached = os.stat(filename)
                        else:
                                stat_cached = os.lstat(filename)
-               except OSError, oe:
+               except OSError as oe:
                        func_call = "stat('%s')" % filename
                        if oe.errno == errno.EPERM:
                                raise OperationNotPermitted(func_call)
@@ -756,7 +756,7 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
                                import portage.data
                                portage.data.lchown(filename, uid, gid)
                        modified = True
-               except OSError, oe:
+               except OSError as oe:
                        func_call = "chown('%s', %i, %i)" % (filename, uid, gid)
                        if oe.errno == errno.EPERM:
                                raise OperationNotPermitted(func_call)
@@ -809,7 +809,7 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
                try:
                        os.chmod(filename, new_mode)
                        modified = True
-               except OSError, oe:
+               except OSError as oe:
                        func_call = "chmod('%s', %s)" % (filename, oct(new_mode))
                        if oe.errno == errno.EPERM:
                                raise OperationNotPermitted(func_call)
@@ -855,7 +855,7 @@ def apply_recursive_permissions(top, uid=-1, gid=-1,
                                uid=uid, gid=gid, mode=dirmode, mask=dirmask)
                        if not applied:
                                all_applied = False
-               except PortageException, e:
+               except PortageException as e:
                        all_applied = False
                        onerror(e)
 
@@ -865,7 +865,7 @@ def apply_recursive_permissions(top, uid=-1, gid=-1,
                                        uid=uid, gid=gid, mode=filemode, mask=filemask)
                                if not applied:
                                        all_applied = False
-                       except PortageException, e:
+                       except PortageException as e:
                                # Ignore InvalidLocation exceptions such as FileNotFound
                                # and DirectoryNotFound since sometimes things disappear,
                                # like when adjusting permissions on DISTCC_DIR.
@@ -890,7 +890,7 @@ def apply_secpass_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
                                stat_cached = os.stat(filename)
                        else:
                                stat_cached = os.lstat(filename)
-               except OSError, oe:
+               except OSError as oe:
                        func_call = "stat('%s')" % filename
                        if oe.errno == errno.EPERM:
                                raise OperationNotPermitted(func_call)
@@ -948,7 +948,7 @@ class atomic_ofstream(ObjectProxy):
                                                encoding=_encodings['fs'], errors='strict'),
                                                mode=mode, **kargs))
                                return
-                       except IOError, e:
+                       except IOError as e:
                                if canonical_path == filename:
                                        raise
                                writemsg(_("!!! Failed to open file: '%s'\n") % tmp_name,
@@ -986,7 +986,7 @@ class atomic_ofstream(ObjectProxy):
                                                pass
                                        except FileNotFound:
                                                pass
-                                       except OSError, oe: # from the above os.stat call
+                                       except OSError as oe: # from the above os.stat call
                                                if oe.errno in (errno.ENOENT, errno.EPERM):
                                                        pass
                                                else:
@@ -997,7 +997,7 @@ class atomic_ofstream(ObjectProxy):
                                # even if an exception is raised.
                                try:
                                        os.unlink(f.name)
-                               except OSError, oe:
+                               except OSError as oe:
                                        pass
 
        def abort(self):
@@ -1025,7 +1025,7 @@ def write_atomic(file_path, content, **kwargs):
                f = atomic_ofstream(file_path, **kwargs)
                f.write(content)
                f.close()
-       except (IOError, OSError), e:
+       except (IOError, OSError) as e:
                if f:
                        f.abort()
                func_call = "write_atomic('%s')" % file_path
@@ -1050,7 +1050,7 @@ def ensure_dirs(dir_path, *args, **kwargs):
        try:
                os.makedirs(dir_path)
                created_dir = True
-       except OSError, oe:
+       except OSError as oe:
                func_call = "makedirs('%s')" % dir_path
                if oe.errno in (errno.EEXIST, errno.EISDIR):
                        pass
index 15a432f519dca3450edab36427d9b4a3500f68f3..54d2eb880c288404649ea46a55d95d344f45a431 100644 (file)
@@ -232,7 +232,7 @@ def xpand(myid,mydest):
        mydata=myid[1]
        try:
                origdir=os.getcwd()
-       except SystemExit, e:
+       except SystemExit as e:
                raise
        except:
                os.chdir("/")
@@ -313,7 +313,7 @@ class tbz2(object):
                        # thus the above sanity check.
                        try:
                                shutil.rmtree(datadir)
-                       except OSError, oe:
+                       except OSError as oe:
                                if oe.errno == errno.ENOENT:
                                        pass
                                else:
@@ -359,7 +359,7 @@ class tbz2(object):
                        self.datapos=a.tell()
                        a.close()
                        return 2
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
                except:
                        return 0
@@ -397,7 +397,7 @@ class tbz2(object):
                        return 0
                try:
                        origdir=os.getcwd()
-               except SystemExit, e:
+               except SystemExit as e:
                        raise
                except:
                        os.chdir("/")
index c3665d9d8c8c9c2bc7435f71b1a0c50157497430..18480294c8b8ae676dbf7df3d7b7c2816615e0a1 100644 (file)
@@ -117,7 +117,7 @@ def parse_metadata_use(mylines, uselist=None):
                uselist = []
        try:
                metadatadom = minidom.parse(mylines)
-       except ExpatError, e:
+       except ExpatError as e:
                raise exception.ParseError("metadata.xml: %s" % (e,))
 
        try:
@@ -289,7 +289,7 @@ def get_commit_message_with_editor(editor, message=None):
                                encoding=_encodings['fs'], errors='strict'),
                                mode='r', encoding=_encodings['content'], errors='replace'
                                ).readlines()
-               except OSError, e:
+               except OSError as e:
                        if e.errno != errno.ENOENT:
                                raise
                        del e