Flatten should always return a list

Currently if flatten() is passed a non-list object, it returns that
object. This is surprising behavior, and prone to causing serious and
numerous problems, since many objects implement the iterable interface,
and thus can be used in cases a list is expected, but with undesirable
results.
This commit is contained in:
Dylan Baker 2017-05-09 12:30:28 -07:00
parent 1a87c967f1
commit e419198ff8
1 changed files with 1 additions and 1 deletions

View File

@ -203,7 +203,7 @@ def classify_unity_sources(compilers, sources):
def flatten(item):
if not isinstance(item, list):
return item
return [item]
result = []
for i in item:
if isinstance(i, list):