From: Matthew Fernandez Date: Sat, 24 Oct 2020 19:15:10 +0000 (-0700) Subject: use shutil.rmtree in preference to pathlib unlink X-Git-Tag: 2.46.0~20^2^2~3^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a6da0e625854e89db3ec173b97e70d1d22efd21;p=graphviz use shutil.rmtree in preference to pathlib unlink The missing_ok argument was only added to pathlib.Path.unlink in Python 3.8. This made the cleanup function fail (sometimes silently) on versions of Python prior to 3.8. --- diff --git a/rtest/rtest.py b/rtest/rtest.py index f11ee78d2..9bb2e5b57 100755 --- a/rtest/rtest.py +++ b/rtest/rtest.py @@ -10,6 +10,7 @@ import os import shutil import tempfile +import shutil import subprocess import sys import platform @@ -300,9 +301,9 @@ def doTest(TEST): TESTTYPES = {} def cleanup(): - pathlib.Path(TMPFILE1).unlink(missing_ok=True) - pathlib.Path(TMPFILE2).unlink(missing_ok=True) - pathlib.Path(TMPINFILE).unlink(missing_ok=True) + shutil.rmtree(TMPFILE1, ignore_errors=True) + shutil.rmtree(TMPFILE2, ignore_errors=True) + shutil.rmtree(TMPINFILE, ignore_errors=True) atexit.register(cleanup) # Set REFDIR