diff --git a/.travis.yml b/.travis.yml index 0354378dfc7a..1df2dee9b143 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,6 +69,9 @@ before_install: - pip install --upgrade virtualenv - virtualenv --python=python venv - source venv/bin/activate + # test with non-ascii in path + - mkdir /tmp/λ + - export PATH=$PATH:/tmp/λ - export PATH=/usr/lib/ccache:$PATH install: diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index f18b6bd337df..004cc5941662 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -354,7 +354,8 @@ def ge(self, level): def checkdep_dvipng(): try: - s = subprocess.Popen(['dvipng', '-version'], stdout=subprocess.PIPE, + s = subprocess.Popen([str('dvipng'), '-version'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = s.communicate() line = stdout.decode('ascii').split('\n')[1] @@ -374,7 +375,7 @@ def checkdep_ghostscript(): for gs_exec in gs_execs: try: s = subprocess.Popen( - [gs_exec, '--version'], stdout=subprocess.PIPE, + [str(gs_exec), '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = s.communicate() if s.returncode == 0: @@ -390,7 +391,7 @@ def checkdep_ghostscript(): def checkdep_tex(): try: - s = subprocess.Popen(['tex', '-version'], stdout=subprocess.PIPE, + s = subprocess.Popen([str('tex'), '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = s.communicate() line = stdout.decode('ascii').split('\n')[0] @@ -404,7 +405,7 @@ def checkdep_tex(): def checkdep_pdftops(): try: - s = subprocess.Popen(['pdftops', '-v'], stdout=subprocess.PIPE, + s = subprocess.Popen([str('pdftops'), '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = s.communicate() lines = stderr.decode('ascii').split('\n') @@ -419,7 +420,8 @@ def checkdep_pdftops(): def checkdep_inkscape(): if checkdep_inkscape.version is None: try: - s = subprocess.Popen(['inkscape', '-V'], stdout=subprocess.PIPE, + s = subprocess.Popen([str('inkscape'), '-V'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = s.communicate() lines = stdout.decode('ascii').split('\n') @@ -436,7 +438,8 @@ def checkdep_inkscape(): def checkdep_xmllint(): try: - s = subprocess.Popen(['xmllint', '--version'], stdout=subprocess.PIPE, + s = subprocess.Popen([str('xmllint'), '--version'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = s.communicate() lines = stderr.decode('ascii').split('\n') diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 178f9b0bd508..b28dfb97fcbf 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -322,7 +322,7 @@ def bin_path(cls): subclass. This is a class method so that the tool can be looked for before making a particular MovieWriter subclass available. ''' - return rcParams[cls.exec_key] + return str(rcParams[cls.exec_key]) @classmethod def isAvailable(cls): diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index 5e77786635b9..8f5e7094b17c 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -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"), "-v"], stderr=subprocess.STDOUT) tools_available.append("pdftocairo") except: pass @@ -191,14 +191,14 @@ 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) 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 +300,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 +318,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 +895,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) diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py index 0800a2819115..1a6c7d28da17 100644 --- a/lib/matplotlib/cbook.py +++ b/lib/matplotlib/cbook.py @@ -1437,7 +1437,7 @@ def report_memory(i=0): # argument may go away pid = os.getpid() if sys.platform == 'sunos5': try: - a2 = Popen('ps -p %d -o osz' % pid, shell=True, + a2 = Popen(str('ps -p %d -o osz') % pid, shell=True, stdout=PIPE).stdout.readlines() except OSError: raise NotImplementedError( @@ -1446,7 +1446,7 @@ def report_memory(i=0): # argument may go away mem = int(a2[-1].strip()) elif sys.platform.startswith('linux'): try: - a2 = Popen('ps -p %d -o rss,sz' % pid, shell=True, + a2 = Popen(str('ps -p %d -o rss,sz') % pid, shell=True, stdout=PIPE).stdout.readlines() except OSError: raise NotImplementedError( @@ -1455,7 +1455,7 @@ def report_memory(i=0): # argument may go away mem = int(a2[1].split()[1]) elif sys.platform.startswith('darwin'): try: - a2 = Popen('ps -p %d -o rss,vsz' % pid, shell=True, + a2 = Popen(str('ps -p %d -o rss,vsz') % pid, shell=True, stdout=PIPE).stdout.readlines() except OSError: raise NotImplementedError( @@ -1464,7 +1464,7 @@ def report_memory(i=0): # argument may go away mem = int(a2[1].split()[0]) elif sys.platform.startswith('win'): try: - a2 = Popen(["tasklist", "/nh", "/fi", "pid eq %d" % pid], + a2 = Popen([str("tasklist"), "/nh", "/fi", "pid eq %d" % pid], stdout=PIPE).stdout.read() except OSError: raise NotImplementedError( diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index 6a50409f2d15..dba90ea78099 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -853,7 +853,7 @@ def find_tex_file(filename, format=None): The library that :program:`kpsewhich` is part of. """ - cmd = ['kpsewhich'] + cmd = [str('kpsewhich')] if format is not None: cmd += ['--format=' + format] cmd += [filename] diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 5d666852578b..308441095705 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -281,7 +281,7 @@ def _call_fc_list(): 'This may take a moment.')) timer.start() try: - out = subprocess.check_output(['fc-list', '--format=%{file}']) + out = subprocess.check_output([str('fc-list'), '--format=%{file}']) except (OSError, subprocess.CalledProcessError): return [] finally: diff --git a/lib/matplotlib/sphinxext/tests/test_tinypages.py b/lib/matplotlib/sphinxext/tests/test_tinypages.py index 51f1e9da1ea3..e3f78c6a96c8 100644 --- a/lib/matplotlib/sphinxext/tests/test_tinypages.py +++ b/lib/matplotlib/sphinxext/tests/test_tinypages.py @@ -42,7 +42,7 @@ def setup_class(cls): cls.html_dir = pjoin(cls.page_build, 'html') cls.doctree_dir = pjoin(cls.page_build, 'doctrees') # Build the pages with warnings turned into errors - cmd = ['sphinx-build', '-W', '-b', 'html', + cmd = [str('sphinx-build'), '-W', '-b', 'html', '-d', cls.doctree_dir, TINY_PAGES, cls.html_dir] diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index 1d476d40e975..e82172d45961 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -132,14 +132,14 @@ def _update_converter(): gs, gs_v = matplotlib.checkdep_ghostscript() if gs_v is not None: def cmd(old, new): - return [gs, '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH', + return [str(gs), '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH', '-sOutputFile=' + new, old] converter['pdf'] = make_external_conversion_command(cmd) converter['eps'] = make_external_conversion_command(cmd) if matplotlib.checkdep_inkscape() is not None: def cmd(old, new): - return ['inkscape', '-z', old, '--export-png', new] + return [str('inkscape'), '-z', old, '--export-png', new] converter['svg'] = make_external_conversion_command(cmd) diff --git a/lib/matplotlib/tests/test_backend_pgf.py b/lib/matplotlib/tests/test_backend_pgf.py index a11ef48f0005..487b23d88d60 100644 --- a/lib/matplotlib/tests/test_backend_pgf.py +++ b/lib/matplotlib/tests/test_backend_pgf.py @@ -30,7 +30,7 @@ def check_for(texsystem): \\@@end """ try: - latex = subprocess.Popen([texsystem, "-halt-on-error"], + latex = subprocess.Popen([str(texsystem), "-halt-on-error"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) stdout, stderr = latex.communicate(header.encode("utf8")) diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index f805cb0f3f03..9d6889427fd5 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -68,7 +68,7 @@ def dvipng_hack_alpha(): try: - p = Popen(['dvipng', '-version'], stdin=PIPE, stdout=PIPE, + p = Popen([str('dvipng'), '-version'], stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=(sys.platform != 'win32')) stdout, stderr = p.communicate() except OSError: