[Epydoc-commits] SF.net SVN: epydoc: [1329] trunk/epydoc/src/epydoc/docparser.py
Brought to you by:
edloper
From: <ed...@us...> - 2006-08-29 21:05:13
|
Revision: 1329 Author: edloper Date: 2006-08-29 14:05:10 -0700 (Tue, 29 Aug 2006) ViewCVS: http://svn.sourceforge.net/epydoc/?rev=1329&view=rev Log Message: ----------- If a docstring can't be decoded using the encoding given in the coding directive at the top of the file, then decode it using epydoc.util.decode_with_backslashreplace() instead. Modified Paths: -------------- trunk/epydoc/src/epydoc/docparser.py Modified: trunk/epydoc/src/epydoc/docparser.py =================================================================== --- trunk/epydoc/src/epydoc/docparser.py 2006-08-29 21:01:43 UTC (rev 1328) +++ trunk/epydoc/src/epydoc/docparser.py 2006-08-29 21:05:10 UTC (rev 1329) @@ -1306,7 +1306,16 @@ # right thing to do; but it will almost always be what the # module's author intended. if isinstance(docstring, str): - docstring = docstring.decode(encoding) + try: + docstring = docstring.decode(encoding) + except UnicodeDecodeError: + # If decoding failed, then fall back on using + # decode_with_backslashreplace, which will map e.g. + # "\xe9" -> u"\\xe9". + docstring = decode_with_backslashreplace(docstring) + log.warning("While parsing %s: docstring is not a unicode " + "string, but it contains non-ascii data." % + prev_line_doc.canonical_name) # If the modified APIDoc is an instance variable, and it has # not yet been added to its class's C{variables} list, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |