Skip to content

Commit

Permalink
Return "" for unwritten symbols in Symbol.config_string
Browse files Browse the repository at this point in the history
The previous return value was None.

Returning "" makes write_config() neater and feels a bit more Pythonic.
It might simplify the implementation of some planned features as well.

This is a small API break, so the major version will be bumped to 4 in
the next release.

Only code that explicitly tests Symbol.config_string against None will
be affected: 'if sym.config_string is None:' will break, but not
'if not sym.config_string:'.
  • Loading branch information
ulfalizer committed Feb 28, 2018
1 parent 3bb590d commit db63301
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions kconfiglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,7 @@ def write_config(self, filename,
if isinstance(item, Symbol):
if not item._written:
item._written = True
config_string = item.config_string
if config_string:
write(config_string)
write(item.config_string)

elif expr_value(node.dep) and \
((item == MENU and expr_value(node.visibility)) or
Expand Down Expand Up @@ -2370,9 +2368,9 @@ class Symbol(object):
config_string:
The .config assignment string that would get written out for the symbol
by Kconfig.write_config(). None if no .config assignment would get
written out. In general, visible symbols, symbols with (active) defaults,
and selected symbols get written out.
by Kconfig.write_config(). Returns the empty string if no .config
assignment would get written out. In general, visible symbols, symbols
with (active) defaults, and selected symbols get written out.
nodes:
A list of MenuNodes for this symbol. Will contain a single MenuNode for
Expand Down Expand Up @@ -2717,7 +2715,7 @@ def config_string(self):
# is a hidden function call due to property magic.
val = self.str_value
if not self._write_to_conf:
return None
return ""

if self.orig_type in (BOOL, TRISTATE):
return "{}{}={}\n" \
Expand Down

0 comments on commit db63301

Please sign in to comment.