My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 202: non-ascii character in raw rst code cause exception
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Oct 08
Type-Defect
Priority-Medium


Sign in to add a comment
 
Reported by solstice.dhiver, Sep 30, 2009
using rst2pdf 0.11

i run rst2pdf on a rst file
it gives me the error:
Traceback (most recent call last):
  File "/usr/bin/rst2pdf", line 8, in <module>
    load_entry_point('rst2pdf==0.11', 'console_scripts', 'rst2pdf')()
  File "/usr/lib/python2.6/site-packages/rst2pdf/createpdf.py", line 1652, 
in main
    compressed=options.compressed)
  File "/usr/lib/python2.6/site-packages/rst2pdf/createpdf.py", line 1271, 
in createPdf
    elements = self.gen_elements(doctree, 0)
  File "/usr/lib/python2.6/site-packages/rst2pdf/createpdf.py", line 574, 
in gen_elements
    node.elements = self.gather_elements(node, depth, style=style)
  File "/usr/lib/python2.6/site-packages/rst2pdf/createpdf.py", line 1150, 
in gather_elements
    r.extend(self.gen_elements(n, depth, style=style))
  File "/usr/lib/python2.6/site-packages/rst2pdf/createpdf.py", line 849, 
in gen_elements
    node.elements = self.gather_elements(node, depth+1)
  File "/usr/lib/python2.6/site-packages/rst2pdf/createpdf.py", line 1150, 
in gather_elements
    r.extend(self.gen_elements(n, depth, style=style))
  File "/usr/lib/python2.6/site-packages/rst2pdf/createpdf.py", line 1104, 
in gen_elements
    node.elements = parseRaw(str(node.astext()))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in 
position 59: ordinal not in range(128)

by printing the node in gen_elements, i was able to find that, this cause 
the problem
<raw format="html" xml:space="preserve"><a 
href="javascript:showAndHide('hide')">Carte du circuit n°8</a>
<span id="hide" style="display:none"><a 
href="img/circuit08_vdb_zoom.jpg"><img alt="Circuit n°8" 
src="img/circuit08_vdb.jpg" /></a></span></raw>

° character seems to be the cause of the problem
so obviously, it is an rst meant to be converted to html. with raw portion 
in html. and it includes some non-ascii character. the file is in utf8

may be that's reasonnable than rst2pdf through such an error ?

however i fix it temporaly by changing 1103 line of createpdf.py from 
node.elements = parseRaw(str(node.astext()))
to
node.elements = parseRaw(node.astext())

???
Comment 1 by roberto.alsina, Sep 30, 2009
I can't reproduce it. I comitted a test case as r1135. Also, rst2pdf has been used 
for many languages that require unicode (you can see the bugs about it not showing 
the right characters in this bug tracker ;-)

It may be this happens if the unicode character is in a specific place, though. 
Could you attach a failing file?
test_issue_202.txt
14 bytes   Download
test_issue_202.pdf
1.8 KB   Download
Comment 2 by roberto.alsina, Oct 08, 2009
Ok, figured it out, failing test case in r1151
Comment 3 by roberto.alsina, Oct 08, 2009
This issue was closed by revision r1152.
Status: Fixed
Mergedinto: -
Sign in to add a comment

Hosted by Google Code