Skip to content
Snippets Groups Projects
Commit f173c2c2 authored by kiilerix's avatar kiilerix
Browse files

vfs: handle shutil.rmtree deprecation of onerror in Python 3.12

Tests would fail with warnings:

  .../mercurial/vfs.py:289: DeprecationWarning: onerror argument is deprecated, use onexc instead

The excinfo changed slightly, but we don't use it anyway.
parent a2df7485
No related branches found
No related tags found
2 merge requests!647branching: merge stable into default,!627A bunch of 3.12 compat stuff
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
""" """
if forcibly: if forcibly:
def onerror(function, path, excinfo): def onexc(function, path, excinfo):
if function is not os.remove: if function is not os.remove:
raise raise
# read-only files cannot be unlinked under Windows # read-only files cannot be unlinked under Windows
...@@ -285,10 +285,17 @@ ...@@ -285,10 +285,17 @@
os.remove(path) os.remove(path)
else: else:
onerror = None onexc = None
return shutil.rmtree( try:
self.join(path), ignore_errors=ignore_errors, onerror=onerror # pytype: disable=wrong-keyword-args
) return shutil.rmtree(
self.join(path), ignore_errors=ignore_errors, onexc=onexc
)
# pytype: enable=wrong-keyword-args
except TypeError: # onexc was introduced in Python 3.12
return shutil.rmtree(
self.join(path), ignore_errors=ignore_errors, onerror=onexc
)
def setflags(self, path: bytes, l: bool, x: bool): def setflags(self, path: bytes, l: bool, x: bool):
return util.setflags(self.join(path), l, x) return util.setflags(self.join(path), l, x)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment