8000 Merge pull request #5931 from ntessore/patch-1 · matplotlib/matplotlib@2ac494f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ac494f

Browse files
committed
Merge pull request #5931 from ntessore/patch-1
use `locale.getpreferredencoding()` to prevent OS X locale issues
1 parent 3b4259e commit 2ac494f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ def _open_file_or_url(fname):
10031003
f.close()
10041004
else:
10051005
fname = os.path.expanduser(fname)
1006-
encoding = locale.getdefaultlocale()[1]
1006+
encoding = locale.getpreferredencoding(do_setlocale=False)
10071007
if encoding is None:
10081008
encoding = "utf-8"
10091009
with io.open(fname, encoding=encoding) as f:
@@ -1044,7 +1044,8 @@ def _rc_params_in_file(fname, fail_on_error=False):
10441044
warnings.warn(
10451045
('Cannot decode configuration file %s with '
10461046
'encoding %s, check LANG and LC_* variables')
1047-
% (fname, locale.getdefaultlocale()[1] or 'utf-8 (default)'))
1047+
% (fname, locale.getpreferredencoding(do_setlocale=False) or
1048+
'utf-8 (default)'))
10481049
raise
10491050

10501051
config = RcParams()

0 commit comments

Comments
 (0)
0