Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

_GSConverter: handle stray 'GS' in output gracefully#20473

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 1 commit intomatplotlib:masterfrommgorny:gs-cruft
Jun 21, 2021

Conversation

mgorny
Copy link
Contributor

PR Summary

Search the GS output stream for either "GS<" or "GS>" explicitly rather
than any "GS", in order to prevent the code from wrongly matching stray
"GS". This fixes a recent test regression on Gentoo where the following
output seems to have been wrongly matched:

**** Error 'gs' ignored -- ExtGState missing from Resources.                              ^^

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • [N/A] New features are documented, with examples if plot related.
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

Fixes#20472

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping@matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

raise ImageComparisonFailure(
(err + b"GS" + stack + b">")
.decode(sys.getfilesystemencoding(), "replace"))
err = self._read_until((b"GS<", b"GS>"))
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT_read_until doesn't support tuples as is (len(terminator) is wrong) and needs to be fixed to support them.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

You are correct, I was so happy about figuring out that.endswith() accepts tuples that I've missed it ;-).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok, so I've figured out that if instead of passing an explicit tuple, I use*terminator arg, I can allow multiple terminators without having to actually change the call sites or having to add a compatibility hack. If you don't like that, I can revert to addingif not isinstance(terminator, tuple) or changing all the call sites.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Heh, wrong. I've just realized that stripping actually makes theerr.endswith() test wrong :-/.

Copy link
Contributor

@anntzeranntzerJun 21, 2021
edited
Loading

Choose a reason for hiding this comment

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

I guess you need aread_until(*terminator, include_terminator=False|True)? Or just always include the terminator (returning a tuple for simpler use) and change all the call sites, perhaps that's slightly nicer APIwise.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok, I think it's ready now. I've noticed another late-night mistake, and fixed it. I've aimed for minimal change / keeping the code simple now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if the whole thing would be simpler by having terminator be a regex instead, and returnmatch.groups()? This way you can just matchr"GS(?:<(\d+))>" instead of having to do two read_untils. (The slight extra cost of doing regex matches should be negligible compared to interacting with the subprocess.)

(If doing so, I would suggest having the argument be always acompiled regex object so that callers have to callre.compile themselves to make it completely clear that the argument is a regex.)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

To be honest, I don't really want to spend more time on it and I don't think it's really important how it's implemented given it's only used in tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

no worries

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks.

@mgornymgornyforce-pushed thegs-cruft branch 3 times, most recently fromb605a5b toff2b05cCompareJune 21, 2021 06:01
Search the GS output stream for either "GS<" or "GS>" explicitly ratherthan any "GS", in order to prevent the code from wrongly matching stray"GS".  This fixes a recent test regression on Gentoo where the followingoutput seems to have been wrongly matched:    **** Error 'gs' ignored -- ExtGState missing from Resources.                                  ^^Fixesmatplotlib#20472
@tacaswelltacaswell added this to thev3.4.3 milestoneJun 21, 2021
@tacaswell
Copy link
Member

Thanks@mgorny ! Congratulations on your first Matplotlib PR merged 🎉 . Hopefully we will hear from you again.

QuLogic added a commit that referenced this pull requestJun 22, 2021
…473-on-v3.4.xBackport PR#20473 on branch v3.4.x (_GSConverter: handle stray 'GS' in output gracefully)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@tacaswelltacaswelltacaswell approved these changes

@anntzeranntzeranntzer approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.4.3
Development

Successfully merging this pull request may close these issues.

test_backend_pgf.py::test_xelatex[pdf] - ValueError: invalid literal for int() with base 10: b'ate missing from Resources. [...]
3 participants
@mgorny@tacaswell@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp