[Epydoc-commits] SF.net SVN: epydoc: [1243] trunk/epydoc/src/epydoc/docwriter/html_colorize.py
Brought to you by:
edloper
From: <ed...@us...> - 2006-07-05 22:54:43
|
Revision: 1243 Author: edloper Date: 2006-07-05 15:54:40 -0700 (Wed, 05 Jul 2006) ViewCVS: http://svn.sourceforge.net/epydoc/?rev=1243&view=rev Log Message: ----------- - Fixed a unicode bug (if the url of a link was unicode, and the source file contained non-ascii characters, then it would fail.) Modified Paths: -------------- trunk/epydoc/src/epydoc/docwriter/html_colorize.py Modified: trunk/epydoc/src/epydoc/docwriter/html_colorize.py =================================================================== --- trunk/epydoc/src/epydoc/docwriter/html_colorize.py 2006-07-05 20:49:46 UTC (rev 1242) +++ trunk/epydoc/src/epydoc/docwriter/html_colorize.py 2006-07-05 22:54:40 UTC (rev 1243) @@ -778,7 +778,10 @@ self.cur_line = [] _next_uid = 0 - + + # [xx] note -- this works with byte strings, not unicode strings! + # I may change it to use unicode eventually, but when I do it + # needs to be changed all at once. def handle_line(self, line): """ Render a single logical line from the module, and write the @@ -809,6 +812,8 @@ # Loop through each token, and colorize it appropriately. for i, (toktype, toktext) in enumerate(line): + assert type(s) is str # *not* unicode! + # For each token, determine its css class and whether it # should link to a url. css_class = None @@ -947,15 +952,22 @@ (uid, css_class_html, tooltip_html, css_class_html, onclick)) elif url: + if isinstance(url, unicode): + url = url.encode('ascii', 'xmlcharrefreplace') s += ('<a%s%s href="%s">' % (tooltip_html, css_class_html, url)) + assert type(s) is str # *not* unicode! elif css_class_html or tooltip_html: s += '<span%s%s>' % (tooltip_html, css_class_html) if i == len(line)-1: s += ' </span>' # Closes <span class="py-line"> s += cgi.escape(toktext) else: - s += self.add_line_numbers(cgi.escape(toktext), css_class) + try: + s += self.add_line_numbers(cgi.escape(toktext), css_class) + except Exception, e: + print (toktext, css_class, toktext.encode('ascii')) + raise if onclick: s += "</a></span>" if url: s += '</a>' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |