Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)