Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: matplotlib.tests.test_backend_pgf.test_pdflatex on Python 3.x #1118

Closed
mdboom opened this issue Aug 20, 2012 · 3 comments
Closed

ERROR: matplotlib.tests.test_backend_pgf.test_pdflatex on Python 3.x #1118

mdboom opened this issue Aug 20, 2012 · 3 comments
Assignees
Milestone

Comments

@mdboom
Copy link
Member

mdboom commented Aug 20, 2012

I'm getting this on Python 3.x only.

======================================================================
ERROR: matplotlib.tests.test_backend_pgf.test_pdflatex
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mdboom/python3/lib/python3.2/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/testing/decorators.py", line 39, in failer
    result = f(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/tests/test_backend_pgf.py", line 30, in backend_switcher
    result = func(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/tests/test_backend_pgf.py", line 82, in test_pdflatex
    compare_figure('pgf_pdflatex.pdf')
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/tests/test_backend_pgf.py", line 40, in compare_figure
    plt.savefig(actual)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/pyplot.py", line 475, in savefig
    return fig.savefig(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/figure.py", line 1229, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backend_bases.py", line 2089, in print_figure
    **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py", line 694, in print_pdf
    self.print_pgf("figure.pgf")
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py", line 674, in print_pgf
    renderer = RendererPgf(self.figure, fh)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py", line 358, in __init__
    self.latexManager = LatexManagerFactory.get_latex_manager()
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py", line 205, in get_latex_manager
    new_inst = LatexManager()
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py", line 243, in __init__
    stdout, stderr = latex.communicate(self.latex_header + latex_end)
  File "/usr/lib64/python3.2/subprocess.py", line 819, in communicate
    return self._communicate(input)
  File "/usr/lib64/python3.2/subprocess.py", line 1425, in _communicate
    stdout, stderr = self._communicate_with_poll(input)
  File "/usr/lib64/python3.2/subprocess.py", line 1492, in _communicate_with_poll
    input_offset += os.write(fd, chunk)
TypeError: 'str' does not support the buffer interface
@ghost ghost assigned pwuertz Aug 20, 2012
@pwuertz
Copy link
Contributor

pwuertz commented Aug 21, 2012

I have never worked with python3 before :/, but it looks like the py3 distinction between strings and bytes. Subprocess.communicate requires a byte buffer that must be explicitly encoded from a str.. (self.latex_header + latex_end).encode('utf-8')..

I'll try to setup a python 3 environment then ^^

@pwuertz
Copy link
Contributor

pwuertz commented Aug 21, 2012

Ok. Another problem. For me, in python3 this doesn't work anymore:

import codecs
import subprocess

proc = subprocess.Popen(["echo"], stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE,
                                  universal_newlines=True)
proc_stdin = codecs.getwriter("utf8")(proc.stdin)
proc_stdin.write("")
proc.communicate()

Apparently, the universal_newlines support is gone. It works if you omit this option. I don't know if this is a problem for windows or osx. For windows it's probably ok since I check for a latex prompt after newline.. and even with '\r\n' the newline is still the last character of a line. What about osx? Are they still using '\r' as a newline? I better find someone to test this :)

@pwuertz
Copy link
Contributor

pwuertz commented Aug 21, 2012

All right, I rewrote the part for the communication with the latex subprocess. Python3 seems to have trouble with subprocess+codecs+latex, so I'm using bytebuffers for reading the stdout now. Python2 tests pass, running a python3 example works, but I can't run the test suite with py3 yet (#745).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants