diff --git a/tabulate/__init__.py b/tabulate/__init__.py index 12a2950..11b0650 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -2488,6 +2488,9 @@ def _expand_iterable(original, num_desired, default): length `num_desired` completely populated with `default will be returned """ if isinstance(original, Iterable) and not isinstance(original, str): + # Coerce to list so non-list iterables (e.g. a tuple passed as + # `rowalign`/`maxcolwidths`) can be concatenated with the padding list. + original = list(original) return original + [default] * (num_desired - len(original)) else: return [default] * num_desired diff --git a/test/test_regression.py b/test/test_regression.py index 9555676..0ce5df3 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -598,3 +598,10 @@ def test_github_escape_pipe_character(): result = tabulate([["foo|bar"]], headers=("spam|eggs",), tablefmt="github") expected = "| spam\\|eggs |\n|:------------|\n| foo\\|bar |" assert_equal(expected, result) + + +def test_rowalign_tuple(): + "Regression: rowalign passed as a tuple must not raise (issue #434)." + expected = tabulate([[1, 2], [3, 4]], rowalign=["top", "bottom"]) + result = tabulate([[1, 2], [3, 4]], rowalign=("top", "bottom")) + assert_equal(expected, result)