Commit 4fa65f84 authored by Julien Muchembled's avatar Julien Muchembled Committed by Xavier Thompson

Ignore NameError in unused conditional configuration sections

Adding new names for expression is currently not possible because
buildout aborts before it tries to upgrade (in-place or bootstrap).
parent e6e1f41c
......@@ -1338,7 +1338,9 @@ class Buildout(DictMixin):
data = self._raw[section]
except KeyError:
raise MissingSection(section)
e = data.get('__unsupported_conditional_expression__')
if e:
raise e
options = self.Options(self, section, data)
self._data[section] = options
options._initialize()
......
......@@ -187,7 +187,12 @@ def parse(fp, fpname, exp_globals=dict):
if not context:
context = exp_globals()
# evaluated expression is in list: get first element
section_condition = eval(expr, context)[0]
try:
section_condition = eval(expr, context)[0]
except NameError as x:
sections.setdefault(sectname, {})[
'__unsupported_conditional_expression__'] = x
continue
# finally, ignore section when an expression
# evaluates to false
if not section_condition:
......@@ -239,6 +244,8 @@ def parse(fp, fpname, exp_globals=dict):
section = sections[sectname]
for name in section:
value = section[name]
if isinstance(value, NameError):
continue
if value[:1].isspace():
section[name] = leading_blank_lines.sub(
'', textwrap.dedent(value.rstrip()))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment