From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 60FE5138247 for ; Thu, 19 Dec 2013 06:17:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 14578E09F8; Thu, 19 Dec 2013 06:17:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A2E06E09F8 for ; Thu, 19 Dec 2013 06:17:10 +0000 (UTC) Received: by smtp.gentoo.org (Postfix, from userid 2097) id EF29033F60A; Thu, 19 Dec 2013 06:17:09 +0000 (UTC) From: antarus@gentoo.org To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] [PATCH] Simplify a bit of code #2 Date: Wed, 18 Dec 2013 22:17:28 -0800 Message-Id: <1387433848-31145-1-git-send-email-antarus@gentoo.org> X-Mailer: git-send-email 1.8.1.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: ad42a7ad-ba1b-4a8e-b688-b19063ed7cbc X-Archives-Hash: 26e0403b9178ad28353cabb8df3f84d3 From: Alec Warner The docstring was wrong, so fix that. If we can open the file (no EnvironmentError raised) we may still fail to parse the file. That was previously guarded by a bare except:, so add that back so we do not introduce any new behavior. Fix dangling reference to myconfig; it will cause a crash. --- catalyst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/catalyst b/catalyst index 47efb90..ab69778 100755 --- a/catalyst +++ b/catalyst @@ -58,7 +58,7 @@ def version(): print "Distributed under the GNU General Public License version 2.1\n" def parse_config(config_path): - """Parse the catalyst config file and generate a targetmap. + """Parse the catalyst config file and update conf_values. TODO(antarus): DANGER: This file modifies global state (conf_values). @@ -91,12 +91,11 @@ def parse_config(config_path): # TODO(antarus): it should be discouraged to call sys.exit() from functions. # One should call sys.exit() from main()..this isn't main(). sys.exit(1) - - try: - myconf.update(cfg.get_values()) except: - print "!!! catalyst: Unable to parse configuration file, "+myconfig + print "!!! catalyst: Unable to parse catalyst configuration: %s" config_path sys.exit(1) + + myconf.update(cfg.get_values()) # now, load up the values into conf_values so that we can use them for x in confdefaults.keys(): -- 1.8.1.2