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

locale breaks test suite #2386

Merged
merged 1 commit into from Sep 6, 2013
Merged

locale breaks test suite #2386

merged 1 commit into from Sep 6, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Sep 6, 2013

When I run the test suite on current master I get a lot of errors that look like this:

======================================================================
ERROR: test suite for <module 'matplotlib.tests.test_axes' from '/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/tests/test_axes.pyc'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/plugins/multiprocess.py", line 788, in run
    self.setUp()
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/suite.py", line 291, in setUp
    self.setupContext(ancestor)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/plugins/multiprocess.py", line 770, in setupContext
    super(NoSharedFixtureContextSuite, self).setupContext(context)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/suite.py", line 314, in setupContext
    try_run(context, names)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/util.py", line 469, in try_run
    return func()
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/tests/__init__.py", line 17, in setup
    locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
  File "/usr/lib/python2.7/locale.py", line 546, in setlocale
    locale = normalize(_build_localename(locale))
  File "/usr/lib/python2.7/locale.py", line 453, in _build_localename
    language, encoding = localetuple
ValueError: too many values to unpack

but

$ python
Python 2.7.5+ (default, Aug  4 2013, 10:07:17) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
'en_US.UTF-8'

Works (or at least does not raise an error). I also noticed this happening on travis.

up-to-date debian sid box, python 2.7

@mdboom
Copy link
Member

mdboom commented Sep 5, 2013

Thanks for finding this. This was actually created by the confluence of the 2to3 -> six changes and the locale fix going in right after one another.

locale.py does this:

    if locale and type(locale) is not type(""):

when best practice would have been

    if locale and not isinstance(locale, basestring):

So when setlocale is passed a Unicode string on Python 2, it tries to parse it as a tuple, which it ain't.

I have a fix I'm running through Travis, and if that works, I'll post and merge here.

mdboom added a commit that referenced this pull request Sep 6, 2013
@mdboom mdboom merged commit b0ad594 into matplotlib:v1.3.x Sep 6, 2013
@mdboom mdboom deleted the fix-locale branch August 7, 2014 13:54
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.

None yet

1 participant