Commit 64eacec9 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Fix TypeError in pprint_table

Convert all fields of table and headers to strings before counting their
length or right-aligning them.

Refs #3365
parent 87f2356c
......@@ -229,12 +229,12 @@ def pprint_table(out, table, headers=None, separator=None):
table.insert(0, headers)
# Find out the max width of each column
widths = [max(map(len, col)) for col in zip(*table)]
widths = [max(map(len, str(col))) for col in zip(*table)]
t_length = sum(widths) + len(sep) * (len(widths) - 1)
if headers:
# pretty print the headers
print >> out, sep.join((val.rjust(width)
print >> out, sep.join((str(val).rjust(width)
for val, width in zip(headers, widths)))
print >> out, "-" * t_length
# remove headers
......@@ -242,7 +242,7 @@ def pprint_table(out, table, headers=None, separator=None):
# print the rest table
for row in table:
print >> out, sep.join((val.rjust(width).encode('utf8')
print >> out, sep.join((str(val).rjust(width).encode('utf8')
for val, width in zip(row, widths)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment