Skip to content

Commit

Permalink
Restore backwards comapability
Browse files Browse the repository at this point in the history
Tests fail locally even for master.  Does reverting to the previous
behaviour fix things?
  • Loading branch information
Vitali Lovich committed May 22, 2015
1 parent 1f5d930 commit 70daa39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions master/buildbot/test/unit/test_util.py
Expand Up @@ -236,12 +236,12 @@ def test_deep(self):
self.assertEqual(util.flatten([[1, 2], 3, [[4]]]),
[1, 2, 3, 4])

def test_deeply_nested(self):
self.assertEqual(util.flatten([5, [6, (7, 8)]]),
[5, 6, 7, 8])
# def test_deeply_nested(self):
# self.assertEqual(util.flatten([5, [6, (7, 8)]]),
# [5, 6, 7, 8])

def test_tuples(self):
self.assertEqual(util.flatten([(1, 2), 3]), [1, 2, 3])
# def test_tuples(self):
# self.assertEqual(util.flatten([(1, 2), 3]), [1, 2, 3])

def test_dict(self):
d = {'a': [5, 6, 7], 'b': [7, 8, 9]}
Expand Down
4 changes: 3 additions & 1 deletion master/buildbot/util/__init__.py
Expand Up @@ -66,7 +66,7 @@ def flattened_iterator(l, types=(list, tuple)):
yield sub_element


def flatten(l, types=(list, tuple)):
def flatten(l, types=(list, )):
"""
Given a list/tuple that potentially contains nested lists/tuples of arbitrary nesting,
flatten into a single dimenstion. In other words, turn [(5, 6, [8, 3]), 2, [2, 1, (3, 4)]]
Expand All @@ -76,6 +76,8 @@ def flatten(l, types=(list, tuple)):
"""
# For backwards compatability, this returned a list, not an iterable.
# Changing to return an iterable could break things.
if not isinstance(l, types):
return l
return list(flattened_iterator(l, types))


Expand Down

0 comments on commit 70daa39

Please sign in to comment.