odfwriter fails when using a config file with non ascii names

Bug #938739 reported by Rafael Villar Burke on 2012-02-22
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-docutils (Ubuntu)

Bug Description

When using the odfwriter (rst2odt) --odf-config-file option to map style names to custom names, and when these names have non-ascii characters in them, the writer fails with an UnicodeDecodeError exception.

The following command generates a traceback and the same command works fine if the rst2odtstyles.ini file is changed so no non-ascii chars appear in it.

$ rst2odt --traceback --stylesheet=Plantilla.odt --odf-config-file=rst2odtstyles.ini Prueba.rst > Prueba.odt
Traceback (most recent call last):
  File "/usr/bin/rst2odt", line 29, in <module>
  File "/usr/lib/pymodules/python2.7/docutils/core.py", line 530, in publish_cmdline_to_binary
    config_section=config_section, enable_exit_status=enable_exit_status)
  File "/usr/lib/pymodules/python2.7/docutils/core.py", line 205, in publish
    output = self.writer.write(self.document, self.destination)
  File "/usr/lib/pymodules/python2.7/docutils/writers/__init__.py", line 76, in write
  File "/usr/lib/pymodules/python2.7/docutils/writers/odf_odt/__init__.py", line 523, in translate
  File "/usr/lib/pymodules/python2.7/docutils/writers/odf_odt/__init__.py", line 532, in assemble_my_parts
    content = self.visitor.content_astext()
  File "/usr/lib/pymodules/python2.7/docutils/writers/odf_odt/__init__.py", line 1229, in content_astext
    return self.astext()
  File "/usr/lib/pymodules/python2.7/docutils/writers/odf_odt/__init__.py", line 1225, in astext
    s1 = ToString(et)
  File "/usr/lib/pymodules/python2.7/docutils/writers/odf_odt/__init__.py", line 303, in ToString
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 815, in write
    serialize(write, self._root, encoding, qnames, namespaces)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 934, in _serialize_xml
    _serialize_xml(write, e, encoding, qnames, None)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 934, in _serialize_xml
    _serialize_xml(write, e, encoding, qnames, None)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 934, in _serialize_xml
    _serialize_xml(write, e, encoding, qnames, None)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 927, in _serialize_xml
    v = _escape_attrib(v, encoding)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1085, in _escape_attrib
    return text.encode(encoding, "xmlcharrefreplace")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 17: ordinal not in range(128)

Jakub Wilk (jwilk) wrote :
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers