Skip to content

Commit 16140c0

Browse files
pmisikp12tic
authored andcommitted
tests: Address deprecation warning in shutil.rmtree(onerror=...)
Ref: https://docs.python.org/3.12/library/shutil.html#shutil.rmtree python/cpython#102828
1 parent 9cb628b commit 16140c0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎master/buildbot/util/private_tempdir.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import os
1717
import shutil
1818
import stat
19+
import sys
1920
import tempfile
2021

2122

@@ -46,5 +47,8 @@ def remove_readonly(func, path, _):
4647
"""
4748
os.chmod(path, stat.S_IWRITE)
4849
func(path)
49-
shutil.rmtree(self.name, onerror=remove_readonly)
50+
if sys.version_info >= (3, 12):
51+
shutil.rmtree(self.name, onexc=remove_readonly)
52+
else:
53+
shutil.rmtree(self.name, onerror=remove_readonly)
5054
self._cleanup_needed = False

0 commit comments

Comments
 (0)