8000 locale.getdefaultlocale() fails on OS X · matplotlib/matplotlib@2f64c8f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f64c8f

Browse files
committed
locale.getdefaultlocale() fails on OS X
For any reason ``locale.getdefaultlocale()`` fails on OS X (returns None), which subsequently produces errors and makes the ``matplotlib`` module unusable. Checking for a ``None`` result and then setting the default encoding to ``"utf-8"`` seems to help.
1 parent 7c1993d commit 2f64c8f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,8 @@ def _open_file_or_url(fname):
992992
else:
993993
fname = os.path.expanduser(fname)
994994
encoding = locale.getdefaultlocale()[1]
995+
if encoding == None:
996+
encoding = "utf-8"
995997
with io.open(fname, encoding=encoding) as f:
996998
yield f
997999

0 commit comments

Comments
 (0)
0