From e419198ff879f74663a7c4d71f2a24f125d27de1 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 9 May 2017 12:30:28 -0700 Subject: [PATCH] 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. --- mesonbuild/mesonlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 54e801630..6937502eb 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -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):