File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1013,20 +1013,26 @@ def find_tex_file(filename, format=None):
10131013 if isinstance (format , bytes ):
10141014 format = format .decode ('utf-8' , errors = 'replace' )
10151015
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+
10161024 cmd = ['kpsewhich' ]
10171025 if format is not None :
10181026 cmd += ['--format=' + format ]
10191027 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 )
10221030 except RuntimeError :
10231031 return ''
10241032 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 ' )
10281034 else :
1029- return os .fsdecode (result )
1035+ return os .fsdecode (result ). rstrip ( ' \n ' )
10301036
10311037
10321038@lru_cache ()
You can’t perform that action at this time.
0 commit comments