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

Try UNIXy and Windowsy ways of setting locale #2396

Merged
merged 1 commit into from Sep 9, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Sep 9, 2013

And warn, rather than fail, if both methods fail.

In response to comments in #2368

@mdboom mdboom mentioned this pull request Sep 9, 2013
@dmcdougall
Copy link
Member

I like the warning. Thanks @mdboom.

@cgohlke
Copy link
Contributor

cgohlke commented Sep 9, 2013

Works for me. Thank you.

mdboom added a commit that referenced this pull request Sep 9, 2013
Try UNIXy and Windowsy ways of setting locale
@mdboom mdboom merged commit 9b593ae into matplotlib:v1.3.x Sep 9, 2013
@pelson
Copy link
Member

pelson commented Sep 18, 2013

These bare excepts are pretty unfriendly - not my favourite solution. Do you know which exceptions we should be trapping?

@pelson
Copy link
Member

pelson commented Sep 18, 2013

$> python tests.py matplotlib.tests.test_legend       
E
======================================================================
ERROR: test suite for <module 'matplotlib.tests.test_legend' from 'build/lib.linux-x86_64-2.7/matplotlib/tests/test_legend.py'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 208, in run
    self.setUp()
  File "lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 291, in setUp
    self.setupContext(ancestor)
  File "lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 314, in setupContext
    try_run(context, names)
  File "lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/util.py", line 478, in try_run
    return func()
  File "build/lib.linux-x86_64-2.7/matplotlib/tests/__init__.py", line 17, in setup
    locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
  File "lib/python2.7/locale.py", line 530, in setlocale
    locale = normalize(_build_localename(locale))
  File "lib/python2.7/locale.py", line 438, in _build_localename
    language, encoding = localetuple
ValueError: too many values to unpack

----------------------------------------------------------------------
Ran 0 tests in 0.013s

FAILED (errors=1)

I'd have said that this was because matplotlib.tests has a from __future__ import unicode_literals and there is a test in the python (v2.7.2) which goes: if locale and type(locale) is not type(""):

The Python bug http://bugs.python.org/issue3067 has been resolved in v2.7.3 by the looks of it. In short, I'm amazed this works on Python 2.6 at all. And it certainly doesn't work for Python v2.7.<3.

@pelson
Copy link
Member

pelson commented Sep 18, 2013

My bad, I see this is resolved in #2386.

@mdboom mdboom deleted the locale-try branch August 7, 2014 13:53
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

4 participants