From 2f7dce28078c8b65a928c9d757d48673ca5e3df4 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 15 Jun 2015 18:54:55 +0200 Subject: Move 'expr is None' check up to _eval_expr(). None should never appear as a subexpression. --- kconfiglib.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index bc8e7e5..a6d112c 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1381,6 +1381,11 @@ class Config(object): def _eval_expr(self, expr): """Evaluates an expression and returns one of the tristate values "n", "m" or "y".""" + + # Handles e.g. an "x if y" condition where the "if y" part is missing. + if expr is None: + return "y" + res = self._eval_expr_2(expr) if res == "m": @@ -1395,9 +1400,6 @@ class Config(object): return res def _eval_expr_2(self, expr): - if expr is None: - return "y" - if isinstance(expr, Symbol): # Non-bool/tristate symbols are always "n" in a tristate sense, # regardless of their value -- cgit v1.2.3