This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: make_table in difflib does not work with unicode
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: georg.brandl, rhettinger, y-unno
Priority: normal Keywords:

Created on 2007-01-17 16:22 by y-unno, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg31059 - (view) Author: y-unno (y-unno) Date: 2007-01-17 16:22
make_table function in difflib.HtmlDiff does not work correctly when input strings are unicode.
This is because the library uses cStringIO.StringIO classes, and cStringIO.StringIO returns strings encoded by the default encoding.
When the default encoding is 'ascii', for example, this behaviour becomes a problem because some unicode characters cannot be encoded in 'ascii'.
 
So, please change cStringIO to StringIO in difflib.py.
When I use StringIO in difflib.py, this function returns unicode strings and no problems occured.
 
This problem occured in Python 2.5/2.4 on Windows XP.
msg31060 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-01-17 21:13
I don't know. Perhaps we should rather fix cStringIO to accept Unicode strings.
msg31061 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-03-08 21:35
Fixed in revs 54229 and 54230.

It wasn't necessary to use StringIO at all.
A simple list of strings and join works fine
(and handles unicode transparently).
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44481
2007-01-17 16:22:22y-unnocreate