@@ -653,6 +653,13 @@ def _get_cachedir():
653
653
get_cachedir = verbose .wrap ('CACHEDIR=%s' , _get_cachedir , always = False )
654
654
655
655
656
+ def _decode_filesystem_path (path ):
657
+ if isinstance (path , bytes ):
658
+ return path .decode (sys .getfilesystemencoding ())
659
+ else :
660
+ return path
661
+
662
+
656
663
def _get_data_path ():
657
664
'get the path to matplotlib data'
658
665
@@ -663,20 +670,22 @@ def _get_data_path():
663
670
'directory' )
664
671
return path
665
672
666
- path = os .sep .join ([os .path .dirname (__file__ ), 'mpl-data' ])
673
+ _file = _decode_filesystem_path (__file__ )
674
+ path = os .sep .join ([os .path .dirname (_file ), 'mpl-data' ])
667
675
if os .path .isdir (path ):
668
676
return path
669
677
670
678
# setuptools' namespace_packages may highjack this init file
671
679
# so need to try something known to be in matplotlib, not basemap
672
680
import matplotlib .afm
673
- path = os .sep .join ([os .path .dirname (matplotlib .afm .__file__ ), 'mpl-data' ])
681
+ _file = _decode_filesystem_path (matplotlib .afm .__file__ )
682
+ path = os .sep .join ([os .path .dirname (_file ), 'mpl-data' ])
674
683
if os .path .isdir (path ):
675
684
return path
676
685
677
686
# py2exe zips pure python, so still need special check
678
687
if getattr (sys , 'frozen' , None ):
679
- exe_path = os .path .dirname (sys .executable )
688
+ exe_path = os .path .dirname (_decode_filesystem_path ( sys .executable ) )
680
689
path = os .path .join (exe_path , 'mpl-data' )
681
690
if os .path .isdir (path ):
682
691
return path
0 commit comments