Skip to content

Commit 45e3d1f

Browse files
authored
Merge pull request #19811 from anntzer/svgcleanup
Fix Inkscape cleanup at exit on Windows.
2 parents bba76b8 + 0e2b757 commit 45e3d1f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/testing/compare.py

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import subprocess
1414
import sys
1515
from tempfile import TemporaryDirectory, TemporaryFile
16+
import weakref
1617

1718
import numpy as np
1819
from PIL import Image
@@ -170,6 +171,9 @@ def __call__(self, orig, dest):
170171
terminator = b"\n>" if old_inkscape else b"> "
171172
if not hasattr(self, "_tmpdir"):
172173
self._tmpdir = TemporaryDirectory()
174+
# On Windows, we must make sure that self._proc has terminated
175+
# (which __del__ does) before clearing _tmpdir.
176+
weakref.finalize(self._tmpdir, self.__del__)
173177
if (not self._proc # First run.
174178
or self._proc.poll() is not None): # Inkscape terminated.
175179
env = {

0 commit comments

Comments
 (0)