Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This commit fixes issue#1317. The locale for the encoding is obtained fromthe Python `locale` module, which can be specified by the `LANG` environmentvariable.This was tested by adding a test rc file encoded in UTF-32-BE, and testing thatit decoded correctly.
'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 comment
The 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 comment
The 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 likerc_params_from_file
returns a newRcParams
object every time, and I don't see them sharing any global state. If you are still concerned, woulddel rc['timezone']
be enough to remove the configuration I've added?
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.
Sorry, my bad. You're right -- the global rcParams isn't updated in this case. This seems fine as-is.
Thanks. This looks good! |
Supports locale-specified encoding for rcfile.
This commit fixes issue#1317. The locale for the encoding is obtained from
the Python
locale
module, which can be specified by theLANG
environmentvariable.
This was tested by adding a test rc file encoded in UTF-32-BE, and testing that
it decoded correctly.