From 0e2b75721029410308f53f3783b30e3d76c06d57 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 29 Mar 2021 18:13:43 +0200 Subject: [PATCH] Fix Inkscape cleanup at exit on Windows. --- lib/matplotlib/testing/compare.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index fb2e55880cde..afb7edb8c828 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -13,6 +13,7 @@ import subprocess import sys from tempfile import TemporaryDirectory, TemporaryFile +import weakref import numpy as np from PIL import Image @@ -170,6 +171,9 @@ def __call__(self, orig, dest): terminator = b"\n>" if old_inkscape else b"> " if not hasattr(self, "_tmpdir"): self._tmpdir = TemporaryDirectory() + # On Windows, we must make sure that self._proc has terminated + # (which __del__ does) before clearing _tmpdir. + weakref.finalize(self._tmpdir, self.__del__) if (not self._proc # First run. or self._proc.poll() is not None): # Inkscape terminated. env = {