diff options
Diffstat (limited to 'pym/portage')
34 files changed, 258 insertions, 258 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index b7c4e9e44..f2a810531 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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) diff --git a/pym/portage/cache/anydbm.py b/pym/portage/cache/anydbm.py index 226c6d7d0..5b771adad 100644 --- a/pym/portage/cache/anydbm.py +++ b/pym/portage/cache/anydbm.py @@ -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) diff --git a/pym/portage/cache/ebuild_xattr.py b/pym/portage/cache/ebuild_xattr.py index fa3937e2f..4bcc6c846 100644 --- a/pym/portage/cache/ebuild_xattr.py +++ b/pym/portage/cache/ebuild_xattr.py @@ -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: diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py index 259be4108..3f46df8b9 100644 --- a/pym/portage/cache/flat_hash.py +++ b/pym/portage/cache/flat_hash.py @@ -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 diff --git a/pym/portage/cache/flat_list.py b/pym/portage/cache/flat_list.py index 1d4dbd28f..cfa3340cd 100644 --- a/pym/portage/cache/flat_list.py +++ b/pym/portage/cache/flat_list.py @@ -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: diff --git a/pym/portage/cache/metadata.py b/pym/portage/cache/metadata.py index ff1227bdb..8b35593c2 100644 --- a/pym/portage/cache/metadata.py +++ b/pym/portage/cache/metadata.py @@ -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: diff --git a/pym/portage/cache/sql_template.py b/pym/portage/cache/sql_template.py index a002d6c06..a4580bdc7 100644 --- a/pym/portage/cache/sql_template.py +++ b/pym/portage/cache/sql_template.py @@ -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() ] diff --git a/pym/portage/cache/sqlite.py b/pym/portage/cache/sqlite.py index d5f765459..073ca2cd8 100644 --- a/pym/portage/cache/sqlite.py +++ b/pym/portage/cache/sqlite.py @@ -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 diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py index 97adb1058..d4573c760 100644 --- a/pym/portage/cache/template.py +++ b/pym/portage/cache/template.py @@ -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") diff --git a/pym/portage/cache/util.py b/pym/portage/cache/util.py index 57d328ced..7b2f1026a 100644 --- a/pym/portage/cache/util.py +++ b/pym/portage/cache/util.py @@ -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() diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index 0a67d2dc0..7b1340dad 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -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 diff --git a/pym/portage/cvstree.py b/pym/portage/cvstree.py index 0fd2a54c5..c3f5d3045 100644 --- a/pym/portage/cvstree.py +++ b/pym/portage/cvstree.py @@ -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 diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index d15953735..3c96a375a 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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 diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 4cc07362a..7d37f365f 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 284d5ff1f..45686ee00 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -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 diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index 49e53c2ee..e9b220a39 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -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)} diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py index 3f86a6d69..e0b9383c5 100644 --- a/pym/portage/eclass_cache.py +++ b/pym/portage/eclass_cache.py @@ -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 diff --git a/pym/portage/elog/__init__.py b/pym/portage/elog/__init__.py index 7bd567cee..c689d821d 100644 --- a/pym/portage/elog/__init__.py +++ b/pym/portage/elog/__init__.py @@ -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) diff --git a/pym/portage/elog/mod_mail.py b/pym/portage/elog/mod_mail.py index 841986b96..ac96f3b20 100644 --- a/pym/portage/elog/mod_mail.py +++ b/pym/portage/elog/mod_mail.py @@ -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 diff --git a/pym/portage/elog/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py index e642dc044..4380146d2 100644 --- a/pym/portage/elog/mod_mail_summary.py +++ b/pym/portage/elog/mod_mail_summary.py @@ -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 diff --git a/pym/portage/env/loaders.py b/pym/portage/env/loaders.py index 5ec3a066f..60e0e1b11 100644 --- a/pym/portage/env/loaders.py +++ b/pym/portage/env/loaders.py @@ -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 diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index dfe2fad59..adab28fab 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -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() diff --git a/pym/portage/locks.py b/pym/portage/locks.py index adf82af81..f2147c5e1 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -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) diff --git a/pym/portage/mail.py b/pym/portage/mail.py index 260455739..a8b384969 100644 --- a/pym/portage/mail.py +++ b/pym/portage/mail.py @@ -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 diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 25893d759..e60850e5f 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -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) diff --git a/pym/portage/output.py b/pym/portage/output.py index baf818f58..06073df71 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -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 diff --git a/pym/portage/process.py b/pym/portage/process.py index 1822a3082..9698743f8 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -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() diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index f52c7fa1a..3b8084ab3 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -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: diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py index 5cd6c6ba1..06ebcadfd 100644 --- a/pym/portage/sets/dbapi.py +++ b/pym/portage/sets/dbapi.py @@ -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) diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py index 13c8508e0..b052a444d 100644 --- a/pym/portage/sets/files.py +++ b/pym/portage/sets/files.py @@ -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 diff --git a/pym/portage/tests/ebuild/test_spawn.py b/pym/portage/tests/ebuild/test_spawn.py index 97a5f42d0..8dfbddd78 100644 --- a/pym/portage/tests/ebuild/test_spawn.py +++ b/pym/portage/tests/ebuild/test_spawn.py @@ -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 diff --git a/pym/portage/update.py b/pym/portage/update.py index 251da88a4..0941ba06b 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -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) diff --git a/pym/portage/util.py b/pym/portage/util.py index 04a799466..5cc3c5e57 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -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 diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py index 15a432f51..54d2eb880 100644 --- a/pym/portage/xpak.py +++ b/pym/portage/xpak.py @@ -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("/") |