From 25e413f09739f1d8515658e1e7fdf061f3d85ff0 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 23 Nov 2018 11:01:25 +0100 Subject: [PATCH] Fix latin-1-ization of Title in eps. We want `title` to be latin-1-encodable, so decoding it as utf-8 (the default) won't work (if there are characters with the highest bit set). --- lib/matplotlib/backends/backend_ps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index c58ff927a604..686c9924aea1 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -972,7 +972,7 @@ def _print_figure( isEPSF = format == 'eps' if isinstance(outfile, (str, getattr(os, "PathLike", ()),)): outfile = title = getattr(os, "fspath", lambda obj: obj)(outfile) - title = title.encode("latin-1", "replace").decode() + title = title.encode("latin-1", "replace").decode("latin-1") passed_in_file_object = False elif is_writable_file_like(outfile): title = None