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
5 changes: 4 additions & 1 deletion tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2262,7 +2262,10 @@ def tabulate(
)

if maxheadercolwidths is not None:
num_cols = len(list_of_lists[0])
if len(list_of_lists):
num_cols = len(list_of_lists[0])
else:
num_cols = 0
if isinstance(maxheadercolwidths, int): # Expand scalar for all columns
maxheadercolwidths = _expand_iterable(
maxheadercolwidths, num_cols, maxheadercolwidths
Expand Down
6 changes: 6 additions & 0 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ def test_exception_on_empty_data_with_maxcolwidths():
assert_equal(result, "")


def test_exception_on_empty_data_with_maxheadercolwidths():
"Regression: exception on empty data when using maxheadercolwidths (github issue #365)"
result = tabulate([], maxheadercolwidths=5)
assert_equal(result, "")


def test_numpy_int64_as_integer():
"Regression: format numpy.int64 as integer (github issue #18)"
try:
Expand Down
Loading