Skip to content

BUG: fix checkout_output with non-ascii paths in PATH #7804

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

Merged
merged 2 commits into from
Jan 13, 2017

Conversation

tacaswell
Copy link
Member

Closes #7715

This ensures that on python2 the values passed into check_output are
bytes. If they are passed in as unicode (due to unicode_literals at
the top of most of our files) they will cause an exception when there
is a path in PATH that has non-ascii values. The reason is that when
locating possible executable our input (as unicode) is concatenated
with the non-ascii path (as bytes) which then fails to encode as ascii
and raises.

The other two places we currently use check_output (setupext.py and
tools/github_stats.py) we do not need this handling as we do not
import unicode_iterals in those files.

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Jan 12, 2017
Closes matplotlib#7715

This ensures that on python2 the values passed into `check_output` or
`Popen` are bytes.  If they are passed in as unicode (due to
unicode_literals at the top of most of our files) they will cause an
exception when there is a path in PATH that has non-ascii values.  The
reason is that when locating possible executable our input (as
unicode) is concatenated with the non-ascii path (as bytes) which then
fails to encode as ascii and raises.

The other two places we currently use `check_output` (setupext.py and
tools/github_stats.py) we do not need this handling as we do not
import unicode_iterals in those files.
@@ -179,7 +179,7 @@ def make_pdf_to_png_converter():
tools_available = []
# check for pdftocairo
try:
check_output(["pdftocairo", "-v"], stderr=subprocess.STDOUT)
check_output([str("pdftocairo"), str("-v")], stderr=subprocess.STDOUT)
Copy link
Contributor

@anntzer anntzer Jan 13, 2017

Choose a reason for hiding this comment

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

Not needed around "-v" (I guess).

"-r %d" % dpi, pdffile, os.path.splitext(pngfile)[0]]
# for some reason this doesn't work without shell
check_output(" ".join(cmd), shell=True, stderr=subprocess.STDOUT)
check_output(cmd, shell=True,
stderr=subprocess.STDOUT)
Copy link
Contributor

Choose a reason for hiding this comment

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

fits on one line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this went through some thrashing..

Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

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

LGTM 👍
@anntzer comments are valid, but minor so I am happy merging as is.

@NelleV
Copy link
Member

NelleV commented Jan 13, 2017

There seems to be a PEP8 problem.

@tacaswell
Copy link
Member Author

This way by far one of the most frustrating bugs to fix I have fixed in a while...not clear why though 🤷‍♂️ .

@anntzer
Copy link
Contributor

anntzer commented Jan 13, 2017

Because Py2? :) Anyways, LGTM (after squashing I'd say).

@NelleV NelleV changed the title BUG: fix checkout_output with non-ascii paths in PATH [MRG+1] BUG: fix checkout_output with non-ascii paths in PATH Jan 13, 2017
@NelleV NelleV merged commit 58fbfbd into matplotlib:v2.x Jan 13, 2017
@tacaswell tacaswell deleted the fix_py2_subprocess branch January 13, 2017 15:26
@QuLogic QuLogic changed the title [MRG+1] BUG: fix checkout_output with non-ascii paths in PATH BUG: fix checkout_output with non-ascii paths in PATH Jan 15, 2017
@anntzer anntzer mentioned this pull request May 10, 2018
6 tasks
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.

3 participants