From 23654b78d55baa46ddd8e18b5f89cc242cc21600 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 26 Nov 2018 12:15:55 +0100 Subject: [PATCH] Restrict postscript title to ascii. The postscript standard makes no reference to the interpretation of non-ascii entities, so assuming an encoding is incorrect. --- 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 6a8b04c902e7..471b7cc071ba 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -970,7 +970,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("latin-1") + title = title.encode("ascii", "replace").decode("ascii") passed_in_file_object = False elif is_writable_file_like(outfile): title = None