Ticket #50717: py-matplotlib-fixlocale.diff

File py-matplotlib-fixlocale.diff, 2.1 KB (added by mojca (Mojca Miklavec), 9 years ago)

An upstream patch to work around UTF-8 locale in matplotlib

  • Portfile

     
    5555
    5656    patchfiles-append   patch-setup.cfg.diff \
    5757                        patch-setupext.py.diff \
    58                         patch-src-macosx.m.diff
     58                        patch-src-macosx.m.diff \
     59                        patch-matplotlib-__init__.py.diff
    5960
    6061    build.env           PKG_CONFIG_PATH="${python.prefix}/lib/pkgconfig"
    6162
  • files/patch-matplotlib-__init__.py.diff

     
     1From 2ac494f71676e8cf824ae7eced1bca0848bb5a59 Mon Sep 17 00:00:00 2001
     2From: Thomas A Caswell <tcaswell@gmail.com>
     3Date: Mon, 15 Feb 2016 15:35:59 -0500
     4Subject: [PATCH] Merge pull request #5931 from ntessore/patch-1
     5
     6use `locale.getpreferredencoding()` to prevent OS X locale issues
     7---
     8 lib/matplotlib/__init__.py | 5 +++--
     9 1 file changed, 3 insertions(+), 2 deletions(-)
     10
     11diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py
     12index f7f4d53..53216ab 100644
     13--- lib/matplotlib/__init__.py
     14+++ lib/matplotlib/__init__.py
     15@@ -997,7 +997,7 @@ def _open_file_or_url(fname):
     16         f.close()
     17     else:
     18         fname = os.path.expanduser(fname)
     19-        encoding = locale.getdefaultlocale()[1]
     20+        encoding = locale.getpreferredencoding(do_setlocale=False)
     21         if encoding is None:
     22             encoding = "utf-8"
     23         with io.open(fname, encoding=encoding) as f:
     24@@ -1038,7 +1038,8 @@ def _rc_params_in_file(fname, fail_on_error=False):
     25             warnings.warn(
     26                 ('Cannot decode configuration file %s with '
     27                  'encoding %s, check LANG and LC_* variables')
     28-                % (fname, locale.getdefaultlocale()[1] or 'utf-8 (default)'))
     29+                % (fname, locale.getpreferredencoding(do_setlocale=False) or
     30+                   'utf-8 (default)'))
     31             raise
     32 
     33     config = RcParams()