Modify ↓
Opened 18 months ago
Closed 18 months ago
#13603 closed defect (fixed)
Python 3.12.0b1: shutil.rmtree: DeprecationWarning: onerror argument is deprecated, use onexc instead
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.6 |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Use |
||
API Changes: | |||
Internal Changes: |
Description
The following is warned on invoking shutil.rmtree(onerror=...)
with Python 3.12.
trac/test.py:555: DeprecationWarning: onerror argument is deprecated, use onexc instead shutil.rmtree(path, onerror=onerror)
See also: https://docs.python.org/3.12/library/shutil.html?highlight=onexc#shutil.rmtree
Patch:
-
trac/test.py
index e6102be75..197b63315 100755
a b def locate(fn): 527 527 return None 528 528 529 529 530 if hasattr(inspect, 'getfullargspec'): # Python 3.11+ 531 _rmtree_argspec = inspect.getfullargspec(shutil.rmtree) 532 # onexc is added in Python 3.12 and onerror is deprecated 533 _rmtree_has_onexc = 'onexc' in getattr(_rmtree_argspec, 'kwonlyargs', []) 534 del _rmtree_argspec 535 else: 536 _rmtree_has_onexc = False 537 538 530 539 def rmtree(path): 531 540 def onerror(function, path, excinfo, retry=1): 532 541 # `os.unlink` and `os.remove` fail for a readonly file on Windows. … … def rmtree(path): 552 561 # Use unicode characters in order to allow non-ansi characters 553 562 # on Windows. 554 563 path = str(path, sys.getfilesystemencoding()) 555 shutil.rmtree(path, onerror=onerror) 564 kwargs = {'onexc' if _rmtree_has_onexc else 'onerror': onerror} 565 shutil.rmtree(path, **kwargs) 556 566 557 567 558 568 INCLUDE_FUNCTIONAL_TESTS = True
Attachments (0)
Change History (2)
comment:1 by , 18 months ago
comment:2 by , 18 months ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Fixed in [17706].
Note:
See TracTickets
for help on using tickets.
I missed that
onexc
andonerror
have different third parameter.New proposed changes in [a822d8e86/jomae.git] (jomae.git@t13603).