8000 use `locale.getpreferredencoding()` · matplotlib/matplotlib@cbac714 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbac714

Browse files
8000
author
Nicolas Tessore
committed
use locale.getpreferredencoding()
1 parent 2a4863c commit cbac714

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
@@ -1002,7 +1002,7 @@ def _open_file_or_url(fname):
10021002
f.close()
10031003
else:
10041004
fname = os.path.expanduser(fname)
1005-
encoding = locale.getdefaultlocale()[1]
1005+
encoding = locale.getpreferredencoding(do_setlocale=False)
10061006
if encoding is None:
10071007
encoding = "utf-8"
10081008
with io.open(fname, encoding=encoding) as f:
@@ -1043,7 +1043,8 @@ def _rc_params_in_file(fname, fail_on_error=False):
10431043
warnings.warn(
10441044
('Cannot decode configuration file %s with '
10451045
'encoding %s, check LANG and LC_* variables')
1046-
% (fname, locale.getdefaultlocale()[1] or 'utf-8 (default)'))
1046+
% (fname, locale.getpreferredencoding(do_setlocale=False) or
1047+
'utf-8 (default)'))
10471048
raise
10481049

10491050
config = RcParams()

0 commit comments

Comments
 (0)
0