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

Commit 58fbfbd

Browse filesBrowse files
authored
Merge pull request matplotlib#7804 from tacaswell/fix_py2_subprocess
BUG: fix checkout_output with non-ascii paths in PATH
2 parents 592e509 + e023faa commit 58fbfbd
Copy full SHA for 58fbfbd

File tree

Expand file treeCollapse file tree

11 files changed

+32
-26
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+32
-26
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ before_install:
6969
- pip install --upgrade virtualenv
7070
- virtualenv --python=python venv
7171
- source venv/bin/activate
72+
# test with non-ascii in path
73+
- mkdir /tmp/λ
74+
- export PATH=$PATH:/tmp/λ
7275
- export PATH=/usr/lib/ccache:$PATH
7376

7477
install:

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ def ge(self, level):
354354

355355
def checkdep_dvipng():
356356
try:
357-
s = subprocess.Popen(['dvipng', '-version'], stdout=subprocess.PIPE,
357+
s = subprocess.Popen([str('dvipng'), '-version'],
358+
stdout=subprocess.PIPE,
358359
stderr=subprocess.PIPE)
359360
stdout, stderr = s.communicate()
360361
line = stdout.decode('ascii').split('\n')[1]
@@ -374,7 +375,7 @@ def checkdep_ghostscript():
374375
for gs_exec in gs_execs:
375376
try:
376377
s = subprocess.Popen(
377-
[gs_exec, '--version'], stdout=subprocess.PIPE,
378+
[str(gs_exec), '--version'], stdout=subprocess.PIPE,
378379
stderr=subprocess.PIPE)
379380
stdout, stderr = s.communicate()
380381
if s.returncode == 0:
@@ -390,7 +391,7 @@ def checkdep_ghostscript():
390391

391392
def checkdep_tex():
392393
try:
393-
s = subprocess.Popen(['tex', '-version'], stdout=subprocess.PIPE,
394+
s = subprocess.Popen([str('tex'), '-version'], stdout=subprocess.PIPE,
394395
stderr=subprocess.PIPE)
395396
stdout, stderr = s.communicate()
396397
line = stdout.decode('ascii').split('\n')[0]
@@ -404,7 +405,7 @@ def checkdep_tex():
404405

405406
def checkdep_pdftops():
406407
try:
407-
s = subprocess.Popen(['pdftops', '-v'], stdout=subprocess.PIPE,
408+
s = subprocess.Popen([str('pdftops'), '-v'], stdout=subprocess.PIPE,
408409
stderr=subprocess.PIPE)
409410
stdout, stderr = s.communicate()
410411
lines = stderr.decode('ascii').split('\n')
@@ -419,7 +420,8 @@ def checkdep_pdftops():
419420
def checkdep_inkscape():
420421
if checkdep_inkscape.version is None:
421422
try:
422-
s = subprocess.Popen(['inkscape', '-V'], stdout=subprocess.PIPE,
423+
s = subprocess.Popen([str('inkscape'), '-V'],
424+
stdout=subprocess.PIPE,
423425
stderr=subprocess.PIPE)
424426
stdout, stderr = s.communicate()
425427
lines = stdout.decode('ascii').split('\n')
@@ -436,7 +438,8 @@ def checkdep_inkscape():
436438

437439
def checkdep_xmllint():
438440
try:
439-
s = subprocess.Popen(['xmllint', '--version'], stdout=subprocess.PIPE,
441+
s = subprocess.Popen([str('xmllint'), '--version'],
442+
stdout=subprocess.PIPE,
440443
stderr=subprocess.PIPE)
441444
stdout, stderr = s.communicate()
442445
lines = stderr.decode('ascii').split('\n')

‎lib/matplotlib/animation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/animation.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def bin_path(cls):
322322
subclass. This is a class method so that the tool can be looked for
323323
before making a particular MovieWriter subclass available.
324324
'''
325-
return rcParams[cls.exec_key]
325+
return str(rcParams[cls.exec_key])
326326

327327
@classmethod
328328
def isAvailable(cls):

‎lib/matplotlib/backends/backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pgf.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# assuming fontconfig is installed and the command 'fc-list' exists
4646
try:
4747
# list scalable (non-bitmap) fonts
48-
fc_list = check_output(['fc-list', ':outline,scalable', 'family'])
48+
fc_list = check_output([str('fc-list'), ':outline,scalable', 'family'])
4949
fc_list = fc_list.decode('utf8')
5050
system_fonts = [f.split(',')[0] for f in fc_list.splitlines()]
5151
system_fonts = list(set(system_fonts))
@@ -179,7 +179,7 @@ def make_pdf_to_png_converter():
179179
tools_available = []
180180
# check for pdftocairo
181181
try:
182-
check_output(["pdftocairo", "-v"], stderr=subprocess.STDOUT)
182+
check_output([str("pdftocairo"), "-v"], stderr=subprocess.STDOUT)
183183
tools_available.append("pdftocairo")
184184
except:
185185
pass
@@ -191,14 +191,14 @@ def make_pdf_to_png_converter():
191191
# pick converter
192192
if "pdftocairo" in tools_available:
193193
def cairo_convert(pdffile, pngfile, dpi):
194-
cmd = ["pdftocairo", "-singlefile", "-png",
194+
cmd = [str("pdftocairo"), "-singlefile", "-png",
195195
"-r %d" % dpi, pdffile, os.path.splitext(pngfile)[0]]
196196
# for some reason this doesn't work without shell
197-
check_output(" ".join(cmd), shell=True, stderr=subprocess.STDOUT)
197+
check_output(cmd, shell=True, stderr=subprocess.STDOUT)
198198
return cairo_convert
199199
elif "gs" in tools_available:
200200
def gs_convert(pdffile, pngfile, dpi):
201-
cmd = [gs, '-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dNOPROMPT',
201+
cmd = [str(gs), '-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dNOPROMPT',
202202
'-sDEVICE=png16m', '-dUseCIEColor', '-dTextAlphaBits=4',
203203
'-dGraphicsAlphaBits=4', '-dDOINTERPOLATE', '-sOutputFile=%s' % pngfile,
204204
'-r%d' % dpi, pdffile]
@@ -300,7 +300,7 @@ def __init__(self):
300300
self.latex_header = LatexManager._build_latex_header()
301301
latex_end = "\n\\makeatletter\n\\@@end\n"
302302
try:
303-
latex = subprocess.Popen([self.texcommand, "-halt-on-error"],
303+
latex = subprocess.Popen([str(self.texcommand), "-halt-on-error"],
304304
stdin=subprocess.PIPE,
305305
stdout=subprocess.PIPE,
306306
cwd=self.tmpdir)
@@ -318,7 +318,7 @@ def __init__(self):
318318
raise LatexError("LaTeX returned an error, probably missing font or error in preamble:\n%s" % stdout)
319319

320320
# open LaTeX process for real work
321-
latex = subprocess.Popen([self.texcommand, "-halt-on-error"],
321+
latex = subprocess.Popen([str(self.texcommand), "-halt-on-error"],
322322
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
323323
cwd=self.tmpdir)
324324
self.latex = latex
@@ -895,7 +895,7 @@ def _print_pdf_to_fh(self, fh, *args, **kwargs):
895895
fh_tex.write(latexcode)
896896

897897
texcommand = get_texcommand()
898-
cmdargs = [texcommand, "-interaction=nonstopmode",
898+
cmdargs = [str(texcommand), "-interaction=nonstopmode",
899899
"-halt-on-error", "figure.tex"]
900900
try:
901901
check_output(cmdargs, stderr=subprocess.STDOUT, cwd=tmpdir)

‎lib/matplotlib/cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ def report_memory(i=0): # argument may go away
14371437
pid = os.getpid()
14381438
if sys.platform == 'sunos5':
14391439
try:
1440-
a2 = Popen('ps -p %d -o osz' % pid, shell=True,
1440+
a2 = Popen(str('ps -p %d -o osz') % pid, shell=True,
14411441
stdout=PIPE).stdout.readlines()
14421442
except OSError:
14431443
raise NotImplementedError(
@@ -1446,7 +1446,7 @@ def report_memory(i=0): # argument may go away
14461446
mem = int(a2[-1].strip())
14471447
elif sys.platform.startswith('linux'):
14481448
try:
1449-
a2 = Popen('ps -p %d -o rss,sz' % pid, shell=True,
1449+
a2 = Popen(str('ps -p %d -o rss,sz') % pid, shell=True,
14501450
stdout=PIPE).stdout.readlines()
14511451
except OSError:
14521452
raise NotImplementedError(
@@ -1455,7 +1455,7 @@ def report_memory(i=0): # argument may go away
14551455
mem = int(a2[1].split()[1])
14561456
elif sys.platform.startswith('darwin'):
14571457
try:
1458-
a2 = Popen('ps -p %d -o rss,vsz' % pid, shell=True,
1458+
a2 = Popen(str('ps -p %d -o rss,vsz') % pid, shell=True,
14591459
stdout=PIPE).stdout.readlines()
14601460
except OSError:
14611461
raise NotImplementedError(
@@ -1464,7 +1464,7 @@ def report_memory(i=0): # argument may go away
14641464
mem = int(a2[1].split()[0])
14651465
elif sys.platform.startswith('win'):
14661466
try:
1467-
a2 = Popen(["tasklist", "/nh", "/fi", "pid eq %d" % pid],
1467+
a2 = Popen([str("tasklist"), "/nh", "/fi", "pid eq %d" % pid],
14681468
stdout=PIPE).stdout.read()
14691469
except OSError:
14701470
raise NotImplementedError(

‎lib/matplotlib/dviread.py

Copy file name to clipboardExpand all lines: lib/matplotlib/dviread.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ def find_tex_file(filename, format=None):
853853
The library that :program:`kpsewhich` is part of.
854854
"""
855855

856-
cmd = ['kpsewhich']
856+
cmd = [str('kpsewhich')]
857857
if format is not None:
858858
cmd += ['--format=' + format]
859859
cmd += [filename]

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def _call_fc_list():
281281
'This may take a moment.'))
282282
timer.start()
283283
try:
284-
out = subprocess.check_output(['fc-list', '--format=%{file}'])
284+
out = subprocess.check_output([str('fc-list'), '--format=%{file}'])
285285
except (OSError, subprocess.CalledProcessError):
286286
return []
287287
finally:

‎lib/matplotlib/sphinxext/tests/test_tinypages.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/tests/test_tinypages.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def setup_class(cls):
4242
cls.html_dir = pjoin(cls.page_build, 'html')
4343
cls.doctree_dir = pjoin(cls.page_build, 'doctrees')
4444
# Build the pages with warnings turned into errors
45-
cmd = ['sphinx-build', '-W', '-b', 'html',
45+
cmd = [str('sphinx-build'), '-W', '-b', 'html',
4646
'-d', cls.doctree_dir,
4747
TINY_PAGES,
4848
cls.html_dir]

‎lib/matplotlib/testing/compare.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/compare.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ def _update_converter():
132132
gs, gs_v = matplotlib.checkdep_ghostscript()
133133
if gs_v is not None:
134134
def cmd(old, new):
135-
return [gs, '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
135+
return [str(gs), '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
136136
'-sOutputFile=' + new, old]
137137
converter['pdf'] = make_external_conversion_command(cmd)
138138
converter['eps'] = make_external_conversion_command(cmd)
139139

140140
if matplotlib.checkdep_inkscape() is not None:
141141
def cmd(old, new):
142-
return ['inkscape', '-z', old, '--export-png', new]
142+
return [str('inkscape'), '-z', old, '--export-png', new]
143143
converter['svg'] = make_external_conversion_command(cmd)
144144

145145

‎lib/matplotlib/tests/test_backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_pgf.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def check_for(texsystem):
3030
\\@@end
3131
"""
3232
try:
33-
latex = subprocess.Popen([texsystem, "-halt-on-error"],
33+
latex = subprocess.Popen([str(texsystem), "-halt-on-error"],
3434
stdin=subprocess.PIPE,
3535
stdout=subprocess.PIPE)
3636
stdout, stderr = latex.communicate(header.encode("utf8"))

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
def dvipng_hack_alpha():
7070
try:
71-
p = Popen(['dvipng', '-version'], stdin=PIPE, stdout=PIPE,
71+
p = Popen([str('dvipng'), '-version'], stdin=PIPE, stdout=PIPE,
7272
stderr=STDOUT, close_fds=(sys.platform != 'win32'))
7373
stdout, stderr = p.communicate()
7474
except OSError:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.