#63 error in latex2e writer

closed
nobody
None
5
2006-06-19
2006-05-15
No

Trying to use the latex2e writer I get:

rst2latex.py patran2bmf.rst patran2bmf.tex
Traceback (most recent call last):
File
"/usr/local/gltools/python/current/bin/rst2latex.py",
line 25, in ?
publish_cmdline(writer_name='latex',
description=description)
File
"/usr/local/gltools/python/current/lib/python2.4/site-packages/docutils/core.py",
line 337, in publish_cmdline
config_section=config_section,
enable_exit_status=enable_exit_status)
File
"/usr/local/gltools/python/current/lib/python2.4/site-packages/docutils/core.py",
line 206, in publish
output = self.writer.write(self.document,
self.destination)
File
"/usr/local/gltools/python/current/lib/python2.4/site-packages/docutils/writers/__init__.py",
line 78, in write
self.translate()
File
"/usr/local/gltools/python/current/lib/python2.4/site-packages/docutils/writers/latex2e/__init__.py",
line 151, in translate
visitor = self.translator_class(self.document)
File
"/usr/local/gltools/python/current/lib/python2.4/site-packages/docutils/writers/latex2e/__init__.py",
line 550, in __init__
self.latex_encoding =
self.to_latex_encoding(settings.output_encoding)
File
"/usr/local/gltools/python/current/lib/python2.4/site-packages/docutils/writers/latex2e/__init__.py",
line 759, in to_latex_encoding
return
docutils_encoding.translate(string.maketrans("",""),"_-").lower()

Kind Regards
Berthold

Discussion

  • Logged In: YES
    user_id=81913

    docutils_encoding is a unicode string for me using the last
    docutils snapshot. The translate method behaves different on
    unicode objects. I fixed the problem for me by replacing
    "translate" by calling "replace twice".

    Kind Regards
    Berthold

    diff -u -b __init__.py~ __init__.py
    --- __init__.py~ 2006-05-13 14:50:15.000000000 +0200
    +++ __init__.py 2006-05-15 12:04:37.000000000 +0200
    @@ -756,7 +756,7 @@
    }
    if tr.has_key(docutils_encoding.lower()):
    return tr[docutils_encoding.lower()]
    - return
    docutils_encoding.translate(string.maketrans("",""),"_-").lower()
    + return docutils_encoding.replace("_",
    "").replace("-", "").lower()

    def language_label(self, docutil_label):
    return self.language.labels[docutil_label]

     
  • Edward Loper
    Edward Loper
    2006-05-16

    Logged In: YES
    user_id=195958

    I'm not sure why you need docutils_encoding to be a
    unicode string, but I see no problems with fixing this
    using the supplied patch. (From the python docs: "For
    Unicode objects, the translate() method does not accept
    the optional deletechars argument.")

    So +1 for applying the patch in hoel's follow-up message.

    (note to hoel -- it's generally better to include patches
    as attachments, rather than pasting them inline to your
    comment.. sourceforge can munge your pasted patch by line-
    wrapping it, etc.)

     
  • Logged In: YES
    user_id=147070

     
    • status: open --> closed