From 5904204aa175d9b4219742a137608eed190cc51b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 19 Oct 2024 16:59:42 -0400 Subject: [PATCH] Correct the order of operations to ensure that failed attempts aren't cached and are thus retried on subsequent operations. Closes #304 --- distutils/dir_util.py | 3 ++- distutils/tests/test_dir_util.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/distutils/dir_util.py b/distutils/dir_util.py index 5696359c..d9782602 100644 --- a/distutils/dir_util.py +++ b/distutils/dir_util.py @@ -32,8 +32,9 @@ def wrap(self, func): def wrapper(path, *args, **kwargs): if path.absolute() in self: return + result = func(path, *args, **kwargs) self.add(path.absolute()) - return func(path, *args, **kwargs) + return result return wrapper diff --git a/distutils/tests/test_dir_util.py b/distutils/tests/test_dir_util.py index ee76d053..fcc37ac5 100644 --- a/distutils/tests/test_dir_util.py +++ b/distutils/tests/test_dir_util.py @@ -112,7 +112,6 @@ def test_copy_tree_exception_in_listdir(self): src = self.tempdirs[-1] dir_util.copy_tree(src, None) - @pytest.mark.xfail(reason="#304") def test_mkpath_exception_uncached(self, monkeypatch, tmp_path): """ Caching should not remember failed attempts.