[PATCH 1 of 4] templater: make it clearer that _flatten() omits None
Yuya Nishihara
yuya at tcha.org
Sun Aug 21 14:53:55 UTC 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1471503307 -32400
# Thu Aug 18 15:55:07 2016 +0900
# Node ID 7e4ca26412a04f858f31f7c409734eb935a3586f
# Parent 5f86818c95e5ea59c48dfceca2e286cd11f9a800
templater: make it clearer that _flatten() omits None
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -917,17 +917,19 @@ def _flatten(thing):
'''yield a single stream from a possibly nested set of iterators'''
if isinstance(thing, str):
yield thing
+ elif thing is None:
+ pass
elif not util.safehasattr(thing, '__iter__'):
- if thing is not None:
- yield str(thing)
+ yield str(thing)
else:
for i in thing:
if isinstance(i, str):
yield i
+ elif i is None:
+ pass
elif not util.safehasattr(i, '__iter__'):
- if i is not None:
- yield str(i)
- elif i is not None:
+ yield str(i)
+ else:
for j in _flatten(i):
yield j
More information about the Mercurial-devel
mailing list