SF #1637850: make_table in difflib did not work with unicode

This commit is contained in:
Raymond Hettinger 2007-03-08 21:33:47 +00:00
parent 5545314ba7
commit 0e520b46ab
1 changed files with 4 additions and 5 deletions

View File

@ -1945,8 +1945,7 @@ class HtmlDiff(object):
fromlist,tolist,flaglist,next_href,next_id = self._convert_flags( fromlist,tolist,flaglist,next_href,next_id = self._convert_flags(
fromlist,tolist,flaglist,context,numlines) fromlist,tolist,flaglist,context,numlines)
import cStringIO s = []
s = cStringIO.StringIO()
fmt = ' <tr><td class="diff_next"%s>%s</td>%s' + \ fmt = ' <tr><td class="diff_next"%s>%s</td>%s' + \
'<td class="diff_next">%s</td>%s</tr>\n' '<td class="diff_next">%s</td>%s</tr>\n'
for i in range(len(flaglist)): for i in range(len(flaglist)):
@ -1954,9 +1953,9 @@ class HtmlDiff(object):
# mdiff yields None on separator lines skip the bogus ones # mdiff yields None on separator lines skip the bogus ones
# generated for the first line # generated for the first line
if i > 0: if i > 0:
s.write(' </tbody> \n <tbody>\n') s.append(' </tbody> \n <tbody>\n')
else: else:
s.write( fmt % (next_id[i],next_href[i],fromlist[i], s.append( fmt % (next_id[i],next_href[i],fromlist[i],
next_href[i],tolist[i])) next_href[i],tolist[i]))
if fromdesc or todesc: if fromdesc or todesc:
header_row = '<thead><tr>%s%s%s%s</tr></thead>' % ( header_row = '<thead><tr>%s%s%s%s</tr></thead>' % (
@ -1968,7 +1967,7 @@ class HtmlDiff(object):
header_row = '' header_row = ''
table = self._table_template % dict( table = self._table_template % dict(
data_rows=s.getvalue(), data_rows=''.join(s),
header_row=header_row, header_row=header_row,
prefix=self._prefix[1]) prefix=self._prefix[1])