Skip to content

Commit

Permalink
fix: Address deprecation warning in rmtree(onerror=...)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Nov 11, 2023
1 parent 5827d6a commit 280c5e2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions copier/template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools related to template management."""
import sys
import re
from collections import ChainMap, defaultdict
from contextlib import suppress
Expand Down Expand Up @@ -198,11 +199,18 @@ class Template:
def _cleanup(self) -> None:
temp_clone = self._temp_clone()
if temp_clone:
rmtree(
temp_clone,
ignore_errors=False,
onerror=handle_remove_readonly,
)
if sys.version_info >= (3, 12):
rmtree(
temp_clone,
ignore_errors=False,
onexc=handle_remove_readonly,
)
else:
rmtree(
temp_clone,
ignore_errors=False,
onerror=handle_remove_readonly,
)

def _temp_clone(self) -> Optional[Path]:
"""Get the path to the temporary clone of the template.
Expand Down

0 comments on commit 280c5e2

Please sign in to comment.