Pngmath error handling code not compatible with Python 3

Dmitry Shachnev avatarDmitry Shachnev created an issue

Forwarded from LP: #1184658.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sphinx/ext/pngmath.py", line 188, in html_visit_math
    fname, depth = render_math(self, '$'+node['latex']+'$')
  File "/usr/lib/python3/dist-packages/sphinx/ext/pngmath.py", line 134, in render_math
    '[stdout]\n%s' % (stderr, stdout))
sphinx.ext.pngmath.MathExtError: latex exited with error:
[stderr]
b''
[stdout]
b"This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)\n restricted \\write18 enabled.\nentering extended mode\n(./math.tex\nLaTeX2e <2011/06/27>\nBabel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, lo\naded.\n(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls\nDocument Class: article 2007/10/19 v1.4h Standard LaTeX document class\n(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo))\n(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty\n\n! LaTeX Error: File `utf8x.def' not found.\n\nType X to quit or <RETURN> to proceed,\nor enter new name. (Default extension: def)\n\nEnter file name: \n! Emergency stop.\n<read *> \n \nl.131 \\endinput\n ^^M\nNo pages of output.\nTranscript written on math.log.\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sphinx/cmdline.py", line 189, in main
    app.build(force_all, filenames)
  File "/usr/lib/python3/dist-packages/sphinx/application.py", line 204, in build
    self.builder.build_update()
  File "/usr/lib/python3/dist-packages/sphinx/builders/__init__.py", line 196, in build_update
    'out of date' % len(to_build))
  File "/usr/lib/python3/dist-packages/sphinx/builders/__init__.py", line 252, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/lib/python3/dist-packages/sphinx/builders/__init__.py", line 292, in write
    self.write_doc(docname, doctree)
  File "/usr/lib/python3/dist-packages/sphinx/builders/html.py", line 419, in write_doc
    self.docwriter.write(doctree, destination)
  File "/usr/lib/python3/dist-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/usr/lib/python3/dist-packages/sphinx/writers/html.py", line 38, in translate
    self.document.walkabout(visitor)
  File "/usr/lib/python3/dist-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/usr/lib/python3/dist-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/usr/lib/python3/dist-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/usr/lib/python3/dist-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/usr/lib/python3/dist-packages/docutils/nodes.py", line 166, in walkabout
    visitor.dispatch_visit(self)
  File "/usr/lib/python3/dist-packages/docutils/nodes.py", line 1627, in dispatch_visit
    return method(node)
  File "/usr/lib/python3/dist-packages/sphinx/ext/pngmath.py", line 190, in html_visit_math
    msg = str(str(exc), 'utf-8', 'replace')
TypeError: decoding str is not supported

Looks like 2to3 converts unicode(str(exc), 'utf-8', 'replace') to str(str(exc), 'utf-8', 'replace'), which won't work. I guess we can just use str(exc) here, but I'm not sure about that.

Comments (1)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.