diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-03-01 00:10:37 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-03-01 00:10:37 +0000 |
commit | edf4aa7cf938f71ba9d8faaefd7870cb66deb24c (patch) | |
tree | 27cce4d02ba3158c1dba7c5d900393939b6bc8d6 /pym/portage.py | |
parent | 21596c1e3202ed9b9ccd59a5a2d6b0d83f94d74d (diff) | |
download | portage-edf4aa7cf938f71ba9d8faaefd7870cb66deb24c.tar.gz portage-edf4aa7cf938f71ba9d8faaefd7870cb66deb24c.tar.bz2 portage-edf4aa7cf938f71ba9d8faaefd7870cb66deb24c.zip |
Make 'import portage' statements more tolerant to broken source statements
in make.conf since exceptions thrown during 'import portage' statements
can practically render the api unusable for api consumers. Thanks to lxnay
for the suggestion. (trunk r9400)
svn path=/main/branches/2.1.2/; revision=9401
Diffstat (limited to 'pym/portage.py')
-rw-r--r-- | pym/portage.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pym/portage.py b/pym/portage.py index 97e3bbf12..b8da8d9b6 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1104,7 +1104,11 @@ class config: @type local_config: Boolean """ - debug = os.environ.get("PORTAGE_DEBUG") == "1" + # When initializing the global portage.settings instance, avoid + # raising exceptions whenever possible since exceptions thrown + # from 'import portage' or 'import portage.exceptions' statements + # can practically render the api unusable for api consumers. + tolerant = "_initializing_globals" in globals() self.already_in_regenerate = 0 @@ -1377,7 +1381,7 @@ class config: self.mygcfg = getconfig( os.path.join(config_root, MAKE_CONF_FILE.lstrip(os.path.sep)), - allow_sourcing=True) + tolerant=tolerant, allow_sourcing=True) if self.mygcfg is None: self.mygcfg = {} @@ -9997,7 +10001,10 @@ def init_legacy_globals(): for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")): kwargs[k] = os.environ.get(envvar, "/") + global _initializing_globals + _initializing_globals = True db = create_trees(**kwargs) + del _initializing_globals settings = db["/"]["vartree"].settings portdb = db["/"]["porttree"].dbapi |