diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index 0c8281b899bc..68b85ca306bc 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -1154,12 +1154,11 @@ def print_figure_impl(fh): xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox) if passed_in_file_object: - if file_requires_unicode(outfile): - with io.open(tmpfile, 'rb') as fh: - outfile.write(fh.read().decode('latin-1')) - else: - with io.open(tmpfile, 'rb') as fh: - outfile.write(fh.read()) + fh = (io.open(tmpfile, 'r', encoding='latin-1') + if file_requires_unicode(outfile) + else io.open(tmpfile, 'rb')) + with fh: + shutil.copyfileobj(fh, outfile) else: with io.open(outfile, 'w') as fh: pass @@ -1354,12 +1353,10 @@ def write(self, *kl, **kwargs): rotated=psfrag_rotated) if is_writable_file_like(outfile): - if file_requires_unicode(outfile): - with io.open(tmpfile, 'rb') as fh: - outfile.write(fh.read().decode('latin-1')) - else: - with io.open(tmpfile, 'rb') as fh: - outfile.write(fh.read()) + with (io.open(tmpfile, 'r', encoding='latin-1') + if file_requires_unicode(outfile) + else io.open(tmpfile, 'rb')) as fh: + shutil.copyfileobj(fh, outfile) else: with io.open(outfile, 'wb') as fh: pass diff --git a/lib/matplotlib/fontconfig_pattern.py b/lib/matplotlib/fontconfig_pattern.py index d1eda70d8ef4..5104c25d3623 100644 --- a/lib/matplotlib/fontconfig_pattern.py +++ b/lib/matplotlib/fontconfig_pattern.py @@ -8,13 +8,10 @@ # This class is defined here because it must be available in: # - The old-style config framework (:file:`rcsetup.py`) -# - The traits-based config framework (:file:`mpltraits.py`) # - The font manager (:file:`font_manager.py`) -# It probably logically belongs in :file:`font_manager.py`, but -# placing it in any of these places would have created cyclical -# dependency problems, or an undesired dependency on traits even -# when the traits-based config framework is not used. +# It probably logically belongs in :file:`font_manager.py`, but placing it +# there would have created cyclical dependency problems. from __future__ import (absolute_import, division, print_function, unicode_literals) diff --git a/lib/matplotlib/type1font.py b/lib/matplotlib/type1font.py index 966761f177e0..de6c030299bf 100644 --- a/lib/matplotlib/type1font.py +++ b/lib/matplotlib/type1font.py @@ -264,7 +264,7 @@ def italicangle(angle): .encode('ascii')) def fontmatrix(array): - array = array.lstrip(b'[').rstrip(b']').strip().split() + array = array.lstrip(b'[').rstrip(b']').split() array = [float(x) for x in array] oldmatrix = np.eye(3, 3) oldmatrix[0:3, 0] = array[::2]