Skip to content

Commit db63301

Browse files
committed
Return "" for unwritten symbols in Symbol.config_string
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:'.
1 parent 3bb590d commit db63301

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

kconfiglib.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,7 @@ def write_config(self, filename,
930930
if isinstance(item, Symbol):
931931
if not item._written:
932932
item._written = True
933-
config_string = item.config_string
934-
if config_string:
935-
write(config_string)
933+
write(item.config_string)
936934

937935
elif expr_value(node.dep) and \
938936
((item == MENU and expr_value(node.visibility)) or
@@ -2370,9 +2368,9 @@ class Symbol(object):
23702368
23712369
config_string:
23722370
The .config assignment string that would get written out for the symbol
2373-
by Kconfig.write_config(). None if no .config assignment would get
2374-
written out. In general, visible symbols, symbols with (active) defaults,
2375-
and selected symbols get written out.
2371+
by Kconfig.write_config(). Returns the empty string if no .config
2372+
assignment would get written out. In general, visible symbols, symbols
2373+
with (active) defaults, and selected symbols get written out.
23762374
23772375
nodes:
23782376
A list of MenuNodes for this symbol. Will contain a single MenuNode for
@@ -2717,7 +2715,7 @@ def config_string(self):
27172715
# is a hidden function call due to property magic.
27182716
val = self.str_value
27192717
if not self._write_to_conf:
2720-
return None
2718+
return ""
27212719

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

0 commit comments

Comments
 (0)