summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-06-18 21:49:36 -0700
committerZac Medico <zmedico@gentoo.org>2013-06-18 21:49:36 -0700
commit81e414bc5ea805ba241d42dedcad97f151976525 (patch)
treedf08966847b19aa66488a7a1e9f06effd99f2d19
parentRepoConfigLoader: handle configparser.Error (diff)
downloadportage-81e414bc5ea805ba241d42dedcad97f151976525.tar.gz
portage-81e414bc5ea805ba241d42dedcad97f151976525.tar.bz2
portage-81e414bc5ea805ba241d42dedcad97f151976525.zip
RepoConfigLoader: return early for parse error
The configparser state is unreliable (prone to odd quirky exceptions) after is has thrown an error, so just return early.
-rw-r--r--pym/portage/repository/config.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index ba9f7ffb2..925a67852 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -471,12 +471,7 @@ class RepoConfigLoader(object):
# it assumes that f.name is a native string rather
# than binary when constructing error messages.
kwargs = {source_kwarg: p}
- try:
- read_file(f, **portage._native_kwargs(kwargs))
- except ConfigParserError as e:
- writemsg(
- _("!!! Error while reading repo config file: %s\n") % e,
- noiselevel=-1)
+ read_file(f, **portage._native_kwargs(kwargs))
finally:
if f is not None:
f.close()
@@ -514,7 +509,22 @@ class RepoConfigLoader(object):
portdir = settings.get('PORTDIR', '')
portdir_overlay = settings.get('PORTDIR_OVERLAY', '')
- self._parse(paths, prepos, ignored_map, ignored_location_map)
+ try:
+ self._parse(paths, prepos, ignored_map, ignored_location_map)
+ except ConfigParserError as e:
+ writemsg(
+ _("!!! Error while reading repo config file: %s\n") % e,
+ noiselevel=-1)
+ # The configparser state is unreliable (prone to odd quirky
+ # exceptions) after is has thrown an error, so just return early.
+ self.prepos = {'DEFAULT': RepoConfig('DEFAULT', {})}
+ self.prepos_order = ()
+ self.ignored_repos = ()
+ self.location_map = {}
+ self.treemap = {}
+ self._prepos_changed = True
+ self._repo_location_list = ()
+ return
# If PORTDIR_OVERLAY contains a repo with the same repo_name as
# PORTDIR, then PORTDIR is overridden.