File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -1013,20 +1013,26 @@ def find_tex_file(filename, format=None):
1013
1013
if isinstance (format , bytes ):
1014
1014
format = format .decode ('utf-8' , errors = 'replace' )
1015
1015
1016
+ if os .name == 'nt' :
1017
+ # On Windows only, kpathsea can use utf-8 for cmd args and output.
1018
+ # The `command_line_encoding` environment variable is set to force it
1019
+ # to always use utf-8 encoding. See mpl issue #11848 for more info.
1020
+ kwargs = dict (env = dict (os .environ , command_line_encoding = 'utf-8' ))
1021
+ else :
1022
+ kwargs = {}
1023
+
1016
1024
cmd = ['kpsewhich' ]
1017
1025
if format is not None :
1018
1026
cmd += ['--format=' + format ]
1019
1027
cmd += [filename ]
1020
- try : # Below: strip final newline.
1021
- result = cbook ._check_and_log_subprocess (cmd , _log )[: - 1 ]
1028
+ try :
1029
+ result = cbook ._check_and_log_subprocess (cmd , _log , ** kwargs )
1022
1030
except RuntimeError :
1023
1031
return ''
1024
1032
if os .name == 'nt' :
1025
- # On Windows only, kpathsea appears to use utf-8 output(?); see
1026
- # __win32_fputs in the kpathsea sources and mpl issue #11848.
1027
- return result .decode ('utf-8' )
1033
+ return result .decode ('utf-8' ).rstrip ('\r \n ' )
1028
1034
else :
1029
- return os .fsdecode (result )
1035
+ return os .fsdecode (result ). rstrip ( ' \n ' )
1030
1036
1031
1037
1032
1038
@lru_cache ()
You can’t perform that action at this time.
0 commit comments