diff options
author | William Deegan <bill@baddogconsulting.com> | 2018-10-17 14:57:56 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2018-10-17 14:57:56 (GMT) |
commit | 9c06f18f8b5da659d95f5bb1d7e86c9f82a790ac (patch) | |
tree | e0debf646cf9b95e25f91d4c7bcdf12a83ba0c7c /src/engine/SCons | |
parent | 15e71f0e56dd21dad0babb09b4e2fe5cbb090be4 (diff) | |
download | SCons-9c06f18f8b5da659d95f5bb1d7e86c9f82a790ac.zip SCons-9c06f18f8b5da659d95f5bb1d7e86c9f82a790ac.tar.gz SCons-9c06f18f8b5da659d95f5bb1d7e86c9f82a790ac.tar.bz2 |
Fix GH Issue #3225 Flatten() doesn't handle dictionary views produces by py3 dict().{items(), values(), keys()}
Diffstat (limited to 'src/engine/SCons')
-rw-r--r-- | src/engine/SCons/Util.py | 10 | ||||
-rw-r--r-- | src/engine/SCons/UtilTests.py | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index b568ce5..6643b72 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -44,7 +44,7 @@ except ImportError: from UserString import UserString try: - from collections.abc import Iterable + from collections.abc import Iterable, MappingView except ImportError: from collections import Iterable @@ -368,7 +368,13 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): DictTypes = (dict, UserDict) ListTypes = (list, UserList) -SequenceTypes = (list, tuple, UserList) + +try: + # Handle getting dictionary views. + SequenceTypes = (list, tuple, UserList, MappingView) +except NameError: + SequenceTypes = (list, tuple, UserList) + # Note that profiling data shows a speed-up when comparing # explicitly with str and unicode instead of simply comparing diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 7ff509e..209c60f 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -875,13 +875,13 @@ class flattenTestCase(unittest.TestCase): def test_scalar(self): """Test flattening a scalar""" result = flatten('xyz') - assert result == ['xyz'], result + self.assertEqual(result,['xyz'], result) def test_dictionary_values(self): """Test flattening the dictionary values""" items = {"a": 1, "b": 2, "c": 3} result = flatten(items.values()) - self.assertEquals(sorted(result),[1,2,3]) + self.assertEqual(sorted(result),[1,2,3]) if __name__ == "__main__": |