-
-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
BUG: fix checkout_output with non-ascii paths in PATH
Closes #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.
- Loading branch information
commit df27722abe45859bfee8bd6fc88c29bcef11c39c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ | |
# assuming fontconfig is installed and the command 'fc-list' exists | ||
try: | ||
# list scalable (non-bitmap) fonts | ||
fc_list = check_output(['fc-list', ':outline,scalable', 'family']) | ||
fc_list = check_output([str('fc-list'), ':outline,scalable', 'family']) | ||
fc_list = fc_list.decode('utf8') | ||
system_fonts = [f.split(',')[0] for f in fc_list.splitlines()] | ||
system_fonts = list(set(system_fonts)) | ||
|
@@ -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) | ||
tools_available.append("pdftocairo") | ||
except: | ||
pass | ||
|
@@ -191,14 +191,15 @@ def make_pdf_to_png_converter(): | |
# pick converter | ||
if "pdftocairo" in tools_available: | ||
def cairo_convert(pdffile, pngfile, dpi): | ||
cmd = ["pdftocairo", "-singlefile", "-png", | ||
cmd = [str("pdftocairo"), "-singlefile", "-png", | ||
"-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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this went through some thrashing.. |
||
return cairo_convert | ||
elif "gs" in tools_available: | ||
def gs_convert(pdffile, pngfile, dpi): | ||
cmd = [gs, '-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dNOPROMPT', | ||
cmd = [str(gs), '-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dNOPROMPT', | ||
'-sDEVICE=png16m', '-dUseCIEColor', '-dTextAlphaBits=4', | ||
'-dGraphicsAlphaBits=4', '-dDOINTERPOLATE', '-sOutputFile=%s' % pngfile, | ||
'-r%d' % dpi, pdffile] | ||
|
@@ -300,7 +301,7 @@ def __init__(self): | |
self.latex_header = LatexManager._build_latex_header() | ||
latex_end = "\n\\makeatletter\n\\@@end\n" | ||
try: | ||
latex = subprocess.Popen([self.texcommand, "-halt-on-error"], | ||
latex = subprocess.Popen([str(self.texcommand), "-halt-on-error"], | ||
stdin=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
cwd=self.tmpdir) | ||
|
@@ -318,7 +319,7 @@ def __init__(self): | |
raise LatexError("LaTeX returned an error, probably missing font or error in preamble:\n%s" % stdout) | ||
|
||
# open LaTeX process for real work | ||
latex = subprocess.Popen([self.texcommand, "-halt-on-error"], | ||
latex = subprocess.Popen([str(self.texcommand), "-halt-on-error"], | ||
stdin=subprocess.PIPE, stdout=subprocess.PIPE, | ||
cwd=self.tmpdir) | ||
self.latex = latex | ||
|
@@ -895,7 +896,7 @@ def _print_pdf_to_fh(self, fh, *args, **kwargs): | |
fh_tex.write(latexcode) | ||
|
||
texcommand = get_texcommand() | ||
cmdargs = [texcommand, "-interaction=nonstopmode", | ||
cmdargs = [str(texcommand), "-interaction=nonstopmode", | ||
"-halt-on-error", "figure.tex"] | ||
try: | ||
check_output(cmdargs, stderr=subprocess.STDOUT, cwd=tmpdir) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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).