Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fixed an enconding bug when checking for gs version #2495

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

Merged
merged 1 commit into from
Nov 8, 2013

Conversation

vlsd
Copy link
Contributor

@vlsd vlsd commented Oct 4, 2013

The text read from stdout needs to be decoded from a byte stream object to an ascii string. As it were one could not import maptlotlib in py3 using the text.usetex = True rc option.

Using python 3.3 on arch, I get the following error:

>  python3                 
Python 3.3.2 (default, Sep  6 2013, 09:30:10) 
[GCC 4.8.1 20130725 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from matplotlib import plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.3/site-packages/matplotlib-1.4.x-py3.3-linux-x86_64.egg/matplotlib/__init__.py", line 961, in <module>
    rcParams['text.usetex'] = checkdep_usetex(rcParams['text.usetex'])
  File "/usr/lib/python3.3/site-packages/matplotlib-1.4.x-py3.3-linux-x86_64.egg/matplotlib/__init__.py", line 461, in checkdep_usetex
    if compare_versions(gs_v, gs_sugg): pass
  File "/usr/lib/python3.3/site-packages/matplotlib-1.4.x-py3.3-linux-x86_64.egg/matplotlib/__init__.py", line 118, in compare_versions
    a = distutils.version.LooseVersion(a)
  File "/usr/lib/python3.3/distutils/version.py", line 310, in __init__
    self.parse(vstring)
  File "/usr/lib/python3.3/distutils/version.py", line 318, in parse
    components = [x for x in self.component_re.split(vstring)
TypeError: can't use a string pattern on a bytes-like object
>>> 

@mdboom
Copy link
Member

mdboom commented Oct 4, 2013

Can you be more specific about the error case? I can not reproduce. Putting text.usetex: True in my matplotlib rc and then doing:

› python3 
Python 3.3.2 (default, Aug 23 2013, 19:00:04) 
[GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from matplotlib import pyplot
/home/mdboom/python3/lib/python3.3/site-packages/matplotlib-1.4.x-py3.3-linux-x86_64.egg/matplotlib/mathtext.py:48: UserWarning: Due to a bug in pyparsing <= 2.0.0 on Python 3.x, packrat parsing has been disabled.  Mathtext rendering will be much slower as a result.  Install pyparsing 2.0.0 or later to improve performance.
  warn("Due to a bug in pyparsing <= 2.0.0 on Python 3.x, packrat parsing "
>>> pyplot.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x7f256286d9d0>]
>>> pyplot.show()

works for me.

What backend and platform are you on?

@vlsd
Copy link
Contributor Author

vlsd commented Oct 4, 2013

Updated with the info. Maybe something changed in python's distutils between Aug 23 and Sept 6?

@mdboom
Copy link
Member

mdboom commented Oct 4, 2013

My bad. I had a glitch with my config file not being read, to text.usetex wasn't actually on. Once that was resolved, I was able to reproduce, and your fix does in fact work and make sense. I'm 👍 on merging this one Travis has confirmed it has no ill effects.

tacaswell added a commit that referenced this pull request Nov 8, 2013
fixed an enconding bug when checking for gs version
@tacaswell tacaswell merged commit 3b5364d into matplotlib:master Nov 8, 2013
@vlsd vlsd deleted the py3gscheck branch November 25, 2013 20:03
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

Successfully merging this pull request may close these issues.

3 participants