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

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 1, 2018

PR Summary

Closes #12308,
Closes #12352 (patch proposed there).

I actually don't think the original PR (#12253) needed to be milestoned to 3.0.x, but now that it has been, this fix needs to go in too.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Oct 1, 2018
@anntzer anntzer added this to the v3.0.x milestone Oct 1, 2018
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')[:-2] # Strip final '\r\n'.
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't it be more clear to just .rstrip() in both cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, technically filenames can end with spaces... not in this case as we're always passing in the extension, but I think "strip the final newlines" (at least rstrip("\r\n")) is clearer in intent.

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't trust any command line tool with trailing whitespace. 😄

Anyway .rstrip("\r\n") would be more safe. Just in case the might be more or less newlines in future versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@timhoffm
Copy link
Member

timhoffm commented Oct 1, 2018

Note: The backport of #12253 is not yet merged (#12302). I don't know what's better: Merging that and backporting this to 3.0.x as well or closing the backport and milestoning this PR to 3.1.

@anntzer
Copy link
Contributor Author

anntzer commented Oct 1, 2018

I'd just close the backport and milestone everything to 3.1.

@ImportanceOfBeingErnest
Copy link
Member

I can report that this fixes the issue for me on windows. However, I'm hesitant to approve this myself, since there are no tests for this and my knowledge on linebreaks in different OS is limited.

@anntzer anntzer force-pushed the dviread-windows-crlf branch from cdd850e to 9192d90 Compare October 1, 2018 19:11
@timhoffm
Copy link
Member

timhoffm commented Oct 1, 2018

Some image comparison tests are broken. Any idea why?

@anntzer
Copy link
Contributor Author

anntzer commented Oct 1, 2018

Nope... they don't even look like they usetex (from the names at least :)), so it's likely unrelated, but dunno...

@ImportanceOfBeingErnest
Copy link
Member

Those image comparissons are broken in other PRs' tests as well. They are only pdf related it seems. Maybe some version in the test suite changed?

@@ -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.

@anntzer anntzer removed status: needs review Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labels Oct 2, 2018
@anntzer
Copy link
Contributor Author

anntzer commented Oct 2, 2018

Superseded by #12351.

@anntzer anntzer closed this Oct 2, 2018
@anntzer anntzer deleted the dviread-windows-crlf branch October 2, 2018 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TeX rendering broken on master with windows #12253 FIX: Handle utf-8 output by kpathsea on Windows -- possibly causing issues
5 participants