-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
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.
3b2a36d
to
df27722
Compare
@@ -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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fits on one line?
There was a problem hiding this comment.
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..
There was a problem hiding this 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.
There seems to be a PEP8 problem. |
This way by far one of the most frustrating bugs to fix I have fixed in a while...not clear why though 🤷♂️ . |
Because Py2? :) Anyways, LGTM (after squashing I'd say). |
Closes #7715
This ensures that on python2 the values passed into
check_output
arebytes. 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 andtools/github_stats.py) we do not need this handling as we do not
import unicode_iterals in those files.