From b2b7d0948ace1d8acb1ac95c8470db294c723a76 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 22 Apr 2020 12:12:34 +0200 Subject: [PATCH] Deprecate support for running svg converter from path contaning newline. Inkscape's batch mode doesn't handle newlines(!) in file names, which tbh doesn't seem to be a too big restriction in practice. Right now we fallback on a specific path to handle that case, but I doubt that it is really hit, given that the batch ghostscript converter likely has the same limitation and no one complained about it for two years. --- doc/api/api_changes_3.3/deprecations.rst | 4 ++++ lib/matplotlib/testing/compare.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/api/api_changes_3.3/deprecations.rst b/doc/api/api_changes_3.3/deprecations.rst index 8acb855753fc..e655805792db 100644 --- a/doc/api/api_changes_3.3/deprecations.rst +++ b/doc/api/api_changes_3.3/deprecations.rst @@ -487,3 +487,7 @@ of all renderer classes is deprecated. `.transforms.AffineDeltaTransform` can be used as a replacement. This API is experimental and may change in the future. + +``testing.compare.make_external_conversion_command`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +... is deprecated. diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index 2f4fdf18c08d..9e93e5d5c8c6 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -1,6 +1,5 @@ """ -Provides a collection of utilities for comparing (image) results. - +Utilities for comparing image results. """ import atexit @@ -17,6 +16,7 @@ import PIL import matplotlib as mpl +from matplotlib import cbook from matplotlib.testing.exceptions import ImageComparisonFailure __all__ = ['compare_images', 'comparable_formats'] @@ -55,6 +55,7 @@ def get_file_hash(path, block_size=2 ** 20): return md5.hexdigest() +@cbook.deprecated("3.3") def make_external_conversion_command(cmd): def convert(old, new): cmdline = cmd(old, new) @@ -194,6 +195,10 @@ def __call__(self, orig, dest): # our encoding is even ASCII compatible... Just fall back on the # slow solution (Inkscape uses `fgets` so it will always stop at a # newline). + cbook.warn_deprecated( + "3.3", message="Support for converting files from paths " + "containing a newline is deprecated since %(since)s and " + "support will be removed %(removal)s") return make_external_conversion_command(lambda old, new: [ 'inkscape', '-z', old, '--export-png', new])(orig, dest) self._proc.stdin.write(orig_b + b" --export-png=" + dest_b + b"\n")