summaryrefslogtreecommitdiffstats
path: root/pym/portage/__init__.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-01 00:04:09 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-01 00:04:09 +0000
commit7e244d16419f05e1072b2ef40dfea77702f81ed6 (patch)
treea801fd231ac513ad69e517d249d3e76fc99ecd71 /pym/portage/__init__.py
parent194a6d0d3d48fe899a992daffeb8b36ff75b120b (diff)
downloadportage-7e244d16419f05e1072b2ef40dfea77702f81ed6.tar.gz
portage-7e244d16419f05e1072b2ef40dfea77702f81ed6.tar.bz2
portage-7e244d16419f05e1072b2ef40dfea77702f81ed6.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. svn path=/main/trunk/; revision=9400
Diffstat (limited to 'pym/portage/__init__.py')
-rw-r--r--pym/portage/__init__.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index e8a8f4f25..dfbe70fc2 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -969,7 +969,11 @@ class config(object):
@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
@@ -1244,7 +1248,7 @@ class config(object):
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 = {}
@@ -6284,7 +6288,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