diff options
author | Marius Mauch <genone@gentoo.org> | 2006-03-24 21:24:32 +0000 |
---|---|---|
committer | Marius Mauch <genone@gentoo.org> | 2006-03-24 21:24:32 +0000 |
commit | 97023941dadc3e9f8308558a70b010a04e5cd12c (patch) | |
tree | 23b7ab1329f9112f04d955666e3c9868ecd919af | |
parent | 47be081dc18f47e8b4955721c3db3812adf475d9 (diff) | |
download | portage-97023941dadc3e9f8308558a70b010a04e5cd12c.tar.gz portage-97023941dadc3e9f8308558a70b010a04e5cd12c.tar.bz2 portage-97023941dadc3e9f8308558a70b010a04e5cd12c.zip |
Fix crappy error handling for PORTAGE_WORKDIR_MODE
svn path=/main/trunk/; revision=2989
-rw-r--r-- | pym/portage.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/pym/portage.py b/pym/portage.py index b4f05f75d..2a4000044 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2613,15 +2613,22 @@ def prepare_build_dirs(myroot, mysettings, cleanup): workdir_mode = 0700 try: - parsed_mode = int(eval(mysettings["PORTAGE_WORKDIR_MODE"])) + mode = mysettings["PORTAGE_WORKDIR_MODE"] + if mode.isdigit(): + parsed_mode = int(mode) + elif mode == "": + raise KeyError() + else: + raise ValueError() if parsed_mode & 07777 != parsed_mode: - raise ValueError("Invalid file mode: %s" % mysettings["PORTAGE_WORKDIR_MODE"]) + raise ValueError("Invalid file mode: %s" % mode) else: workdir_mode = parsed_mode except KeyError, e: - writemsg("!!! PORTAGE_WORKDIR_MODE is unset, using %s." % oct(workdir_mode)) - except (ValueError, SyntaxError), e: - writemsg("%s\n" % e) + writemsg("!!! PORTAGE_WORKDIR_MODE is unset, using %s.\n" % oct(workdir_mode)) + except ValueError, e: + if len(str(e)) > 0: + writemsg("%s\n" % e) writemsg("!!! Unable to parse PORTAGE_WORKDIR_MODE='%s', using %s.\n" % \ (mysettings["PORTAGE_WORKDIR_MODE"], oct(workdir_mode))) mysettings["PORTAGE_WORKDIR_MODE"] = oct(workdir_mode) |