File tree Expand file tree Collapse file tree 3 files changed +20
-13
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +20
-13
lines changed
Original file line number Diff line number Diff line change @@ -2133,15 +2133,23 @@ def _check_and_log_subprocess(command, logger, **kwargs):
2133
2133
proc = subprocess .run (
2134
2134
command , stdout = subprocess .PIPE , stderr = subprocess .PIPE , ** kwargs )
2135
2135
if proc .returncode :
2136
+ stdout = proc .stdout
2137
+ if isinstance (stdout , bytes ):
2138
+ stdout = stdout .decode ()
2139
+ stderr = proc .stderr
2140
+ if isinstance (stderr , bytes ):
2141
+ stderr = stderr .decode ()
2136
2142
raise RuntimeError (
2137
2143
f"The command\n "
2138
2144
f" { _pformat_subprocess (command )} \n "
2139
2145
f"failed and generated the following output:\n "
2140
- f"{ proc . stdout . decode ( 'utf-8' ) } \n "
2146
+ f"{ stdout } \n "
2141
2147
f"and the following error:\n "
2142
- f"{ proc .stderr .decode ('utf-8' )} " )
2143
- logger .debug ("stdout:\n %s" , proc .stdout )
2144
- logger .debug ("stderr:\n %s" , proc .stderr )
2148
+ f"{ stderr } " )
2149
+ if proc .stdout :
2150
+ logger .debug ("stdout:\n %s" , proc .stdout )
2151
+ if proc .stderr :
2152
+ logger .debug ("stderr:\n %s" , proc .stderr )
2145
2153
return proc .stdout
2146
2154
2147
2155
Original file line number Diff line number Diff line change 25
25
from pathlib import Path
26
26
import re
27
27
import struct
28
+ import sys
28
29
import textwrap
29
30
30
31
import numpy as np
@@ -1067,9 +1068,11 @@ def find_tex_file(filename, format=None):
1067
1068
# On Windows only, kpathsea can use utf-8 for cmd args and output.
1068
1069
# The `command_line_encoding` environment variable is set to force it
1069
1070
# to always use utf-8 encoding. See Matplotlib issue #11848.
1070
- kwargs = dict (env = dict (os .environ , command_line_encoding = 'utf-8' ))
1071
- else :
1072
- kwargs = {}
1071
+ kwargs = {'env' : {** os .environ , 'command_line_encoding' : 'utf-8' },
1072
+ 'encoding' : 'utf-8' }
1073
+ else : # On POSIX, run through the equivalent of os.fsdecode().
1074
+ kwargs = {'encoding' : sys .getfilesystemencoding (),
1075
+ 'errors' : 'surrogatescape' }
1073
1076
1074
1077
cmd = ['kpsewhich' ]
1075
1078
if format is not None :
@@ -1079,10 +1082,7 @@ def find_tex_file(filename, format=None):
1079
1082
result = cbook ._check_and_log_subprocess (cmd , _log , ** kwargs )
1080
1083
except RuntimeError :
1081
1084
return ''
1082
- if os .name == 'nt' :
1083
- return result .decode ('utf-8' ).rstrip ('\r \n ' )
1084
- else :
1085
- return os .fsdecode (result ).rstrip ('\n ' )
1085
+ return result .rstrip ('\n ' )
1086
1086
1087
1087
1088
1088
@lru_cache ()
Original file line number Diff line number Diff line change @@ -131,8 +131,7 @@ def get_font_config(self):
131
131
font_family , font , self .font_info [font .lower ()])
132
132
break
133
133
else :
134
- _log .debug ('%s font is not compatible with usetex.' ,
135
- font_family )
134
+ _log .debug ('%s font is not compatible with usetex.' , font )
136
135
else :
137
136
_log .info ('No LaTeX-compatible font found for the %s font '
138
137
'family in rcParams. Using default.' , font_family )
You can’t perform that action at this time.
0 commit comments