-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Supports locale-specified encoding for rcfile. #3575
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import six | ||
|
||
import io | ||
import os | ||
import sys | ||
import warnings | ||
|
@@ -140,6 +141,18 @@ def test_Bug_2543_newer_python(): | |
with mpl.rc_context(): | ||
mpl.rcParams['svg.fonttype'] = True | ||
|
||
def test_Issue_1713(): | ||
utf32_be = os.path.join(os.path.dirname(__file__), | ||
'test_utf32_be_rcparams.rc') | ||
old_lang = os.environ.get('LANG', None) | ||
os.environ['LANG'] = 'en_US.UTF-32-BE' | ||
rc = mpl.rc_params_from_file(utf32_be, True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will end up changing the rcParams, which may cause subsequent tests to fail if they rely on the rcParams being a certain thing. We may have to test lower down by calling _open_file_or_url directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Testing the module by invoking a "private" method is something I'd prefer not to do. It looks to me like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, my bad. You're right -- the global rcParams isn't updated in this case. This seems fine as-is. |
||
if old_lang: | ||
os.environ['LANG'] = old_lang | ||
else: | ||
del os.environ['LANG'] | ||
print(rc.get('timezone') == 'UTC') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be an assert so the test will fail if it's not what we expect, i.e.:
|
||
|
||
if __name__ == '__main__': | ||
import nose | ||
nose.runmodule(argv=['-s', '--with-doctest'], exit=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this test fail if the OS doesn't have the
en_US.UTF-32-BE
locale installed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luckily, the encodings come from python's standard library not from the OS. UTF-32-BE has been available in at least Python 2.7 and newer. What're the oldest Pythons that matplotlib supports? I couldn't find this from a cursory glance at the matplotlib documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I misunderstood your question. This test works fine on my mac which doesn't support this locale. Which is why I think our earlier approach of
locale.getpreferredencoding()
failed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Since we're using
getdefaultlocale
rather thangetpreferredencoding
, we should be ok, and my concern is probably moot.