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

Appearance settings

MAINT: work around non-zero exit status of "pdftops -v" command. #14395

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

Conversation

congma
Copy link
Contributor

@congma congma commented May 31, 2019

In the function responsible for probing the presence of external
command (_get_executable_info), add an optional argument
ignore_error (default False). If set to True, the external command is
allowed to exit with non-zero status, and the content of the output is
used anyway.

This works around the problem with certain xpdf versions where the
exit status of pdftops -v command is nonzero.

Compatibility is maintained because the optional argument defaults to
False which doesn't introduce any new behaviour.

PR Summary

PR Checklist

- [ ] Has Pytest style unit tests not applicable

  • Code is Flake 8 compliant
    - [ ] New features are documented, with examples if plot related not applicable
    - [ ] 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
Copy link
Contributor

anntzer commented May 31, 2019

  1. do you have a reference (a bug report, etc.) for pdftops returning nonzero?
  2. perhaps we should just always take whatever comes out on stdout, as long as it matches the regex, and ignore whether the return code is zero or not?

@congma
Copy link
Contributor Author

congma commented May 31, 2019

1. do you have a reference (a bug report, etc.) for pdftops returning nonzero?

Unfortunately I couldn't find a public bug report. The problem encountered here was detected with Homebrew's xpdf package (version 4.01.01), because of the following code in xpdf/pdftops.cc:

  ok = parseArgs(argDesc, &argc, argv);
  if (!ok || argc < 2 || argc > 3 || printVersion || printHelp) {
    fprintf(stderr, "pdftops version %s\n", xpdfVersion);
    fprintf(stderr, "%s\n", xpdfCopyright);
    if (!printVersion) {
      printUsage("pdftops", "<PDF-file> [<PS-file>]", argDesc);
    }
    exit(1);
  }

In other words, even if -v is the only command-line argument explicitly demanded and nothing else is wrong, the program will exit as if there were a problem with the cmdline. (I'll file a separate bug report to xpdf developers).

If the ps back-end is used and ps.usedistiller is set to "xpdf", this problem can be triggered at import time.

@anntzer
Copy link
Contributor

anntzer commented May 31, 2019

Seems fair.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

While this is suppressing a CalledProcessError it's actually the exist code that determines this, so maybe better call it ignore_exit_code?

congma added 2 commits June 2, 2019 11:53
In the function responsible for probing the presence of external
command ("_get_executable_info"), add an optional argument
"ignore_error" (default False). If set to True, the external command is
allowed to exit with non-zero status, and the content of the output is
used anyway.

This works around the problem with certain xpdf versions where the
exit status of "pdftops -v" command is nonzero.

Compatibility is maintained because the optional argument defaults to
False which doesn't introduce any new behaviour.
The optional argument "ignore_error" is changed to "ignore_exit_code"
based on the suggestion of @timhoffm.
@congma congma force-pushed the work-around-nonzero-exit-status-when-guessing-implementation-via-subprocess branch from c6cedea to ad5ffed Compare June 2, 2019 09:57
@congma
Copy link
Contributor Author

congma commented Jun 2, 2019

While this is suppressing a CalledProcessError it's actually the exist code that determines this, so maybe better call it ignore_exit_code?

This is good suggestion and I've updated accordingly (and force-pushed after rebasing).

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

👍 looks good to me, thanks for your first code contribution to Matplotlib. Should we backport this to 3.1.1, and maybe the 2.x series too?

@tacaswell tacaswell added this to the v2.2.5 milestone Jun 8, 2019
@tacaswell tacaswell merged commit fd9c59d into matplotlib:master Jun 8, 2019
@lumberbot-app
Copy link

lumberbot-app bot commented Jun 8, 2019

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v2.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 fd9c59dc54be14077dd0124c3046a99526bf188a
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #14395: MAINT: work around non-zero exit status of "pdftops -v" command.'
  1. Push to a named branch :
git push YOURFORK v2.2.x:auto-backport-of-pr-14395-on-v2.2.x
  1. Create a PR against branch v2.2.x, I would have named this PR:

"Backport PR #14395 on branch v2.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

@tacaswell
Copy link
Member

Thanks @congma !

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jun 8, 2019
timhoffm added a commit that referenced this pull request Jun 9, 2019
…395-on-v3.1.x

Backport PR #14395 on branch v3.1.x (MAINT: work around non-zero exit status of "pdftops -v" command.)
@tacaswell tacaswell modified the milestones: v2.2.5, v3.1.2 Sep 5, 2019
@tacaswell
Copy link
Member

This code path is not in 2.2.x, it came in via 32ed5bd which is in 3.0+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.