File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2262,7 +2262,10 @@ def tabulate(
22622262 )
22632263
22642264 if maxheadercolwidths is not None :
2265- num_cols = len (list_of_lists [0 ])
2265+ if len (list_of_lists ):
2266+ num_cols = len (list_of_lists [0 ])
2267+ else :
2268+ num_cols = 0
22662269 if isinstance (maxheadercolwidths , int ): # Expand scalar for all columns
22672270 maxheadercolwidths = _expand_iterable (
22682271 maxheadercolwidths , num_cols , maxheadercolwidths
Original file line number Diff line number Diff line change @@ -515,6 +515,12 @@ def test_exception_on_empty_data_with_maxcolwidths():
515515 assert_equal (result , "" )
516516
517517
518+ def test_exception_on_empty_data_with_maxheadercolwidths ():
519+ "Regression: exception on empty data when using maxheadercolwidths (github issue #365)"
520+ result = tabulate ([], maxheadercolwidths = 5 )
521+ assert_equal (result , "" )
522+
523+
518524def test_numpy_int64_as_integer ():
519525 "Regression: format numpy.int64 as integer (github issue #18)"
520526 try :
You can’t perform that action at this time.
0 commit comments