From 6f16cb2032f967aa420c90255bad54954479c0c3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 1 Apr 2022 18:04:03 -0400 Subject: [PATCH 1/2] MNT: if process dies, make sure we close the streams This prevents pytest from failing other test due to auto-closed resources. --- lib/matplotlib/testing/compare.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index 0a2ae17b36d0..a54108c78980 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -147,6 +147,11 @@ def __call__(self, orig, dest): weakref.finalize(self._tmpdir, self.__del__) if (not self._proc # First run. or self._proc.poll() is not None): # Inkscape terminated. + if self._proc is not None and self._proc.poll() is not None: + for stream in filter(None, [self._proc.stdin, + self._proc.stdout, + self._proc.stderr]): + stream.close() env = { **os.environ, # If one passes e.g. a png file to Inkscape, it will try to From 9e5fe1355ec8e1619934096e3abc8002624c8d8f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 1 Apr 2022 18:05:31 -0400 Subject: [PATCH 2/2] MNT: put inkscape history/config files in temp working directory Inkscape will fail to create directories in /dev/null, be very unhappy about this, and fail to convent all of the svg. --- lib/matplotlib/testing/compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index a54108c78980..5e0ddc593e03 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -161,7 +161,7 @@ def __call__(self, orig, dest): # just be reported as a regular exception below). "DISPLAY": "", # Do not load any user options. - "INKSCAPE_PROFILE_DIR": os.devnull, + "INKSCAPE_PROFILE_DIR": self._tmpdir.name, } # Old versions of Inkscape (e.g. 0.48.3.1) seem to sometimes # deadlock when stderr is redirected to a pipe, so we redirect it