Skip to content

Fix stripping of CRLF on Windows. #12356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,16 +1017,16 @@ def find_tex_file(filename, format=None):
if format is not None:
cmd += ['--format=' + format]
cmd += [filename]
try: # Below: strip final newline.
result = cbook._check_and_log_subprocess(cmd, _log)[:-1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change?

This is a little hard to review in the absence of tests; What test should I run locally to make sure this doesn't break?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe simply replace [:-1] with .rstrip('\r\n')?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what we do below... I don't mind doing it for both windows and non-windows, it won't matter in practice.
The main difference is with the encoding though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jklymak I do not know why old TEST_ALL: "yes" builds were removed without making at least a single newer one. I have started a TEST_ALL: "yes" Appveyor build https://ci.appveyor.com/project/Kojoley/matplotlib/build/1.0.133 in my fork to see how long it takes.

try:
result = cbook._check_and_log_subprocess(cmd, _log)
except RuntimeError:
return ''
if os.name == 'nt':
# On Windows only, kpathsea appears to use utf-8 output(?); see
# __win32_fputs in the kpathsea sources and mpl issue #11848.
return result.decode('utf-8')
return result.decode('utf-8').rstrip('\r\n')
else:
return os.fsdecode(result)
return os.fsdecode(result).rstrip('\n')


@lru_cache()
Expand Down