Commit 46b50f9b 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 9727dbb5
......@@ -1337,7 +1337,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