8000 use `locale.getpreferredencoding()` to prevent OS X locale issues by ntessore · Pull Request #5931 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

use locale.getpreferredencoding() to prevent OS X locale issues #5931

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
Feb 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ def _open_file_or_url(fname):
f.close()
else:
fname = os.path.expanduser(fname)
encoding = locale.getdefaultlocale()[1]
encoding = locale.getpreferredencoding(do_setlocale=False)
if encoding is None:
encoding = "utf-8"
with io.open(fname, encoding=encoding) as f:
Expand Down Expand Up @@ -1043,7 +1043,8 @@ def _rc_params_in_file(fname, fail_on_error=False):
warnings.warn(
('Cannot decode configuration file %s with '
'encoding %s, check LANG and LC_* variables')
% (fname, locale.getdefaultlocale()[1] or 'utf-8 (default)'))
% (fname, locale.getpreferredencoding(do_setlocale=False) or
'utf-8 (default)'))
raise

config = RcParams()
Expand Down
0