Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b7c057a1
Commit
b7c057a1
authored
Nov 20, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28666: Now test.support.rmtree is able to remove unwritable or
unreadable directories.
parent
bd20530e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
Lib/test/test_support.py
Lib/test/test_support.py
+32
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_support.py
View file @
b7c057a1
...
...
@@ -236,7 +236,38 @@ if sys.platform.startswith("win"):
else
:
_unlink
=
os
.
unlink
_rmdir
=
os
.
rmdir
_rmtree
=
shutil
.
rmtree
def
_rmtree
(
path
):
import
stat
try
:
shutil
.
rmtree
(
path
)
return
except
EnvironmentError
:
pass
def
force_run
(
path
,
func
,
*
args
):
try
:
return
func
(
*
args
)
except
EnvironmentError
as
err
:
if
verbose
>=
2
:
print
(
'%s: %s'
%
(
err
.
__class__
.
__name__
,
err
))
print
(
're-run %s%r'
%
(
func
.
__name__
,
args
))
os
.
chmod
(
path
,
stat
.
S_IRWXU
)
return
func
(
*
args
)
def
_rmtree_inner
(
path
):
for
name
in
force_run
(
path
,
os
.
listdir
,
path
):
fullname
=
os
.
path
.
join
(
path
,
name
)
try
:
mode
=
os
.
lstat
(
fullname
).
st_mode
except
EnvironmentError
:
mode
=
0
if
stat
.
S_ISDIR
(
mode
):
_rmtree_inner
(
fullname
)
force_run
(
path
,
os
.
rmdir
,
fullname
)
else
:
force_run
(
path
,
os
.
unlink
,
fullname
)
_rmtree_inner
(
path
)
os
.
rmdir
(
path
)
def
unlink
(
filename
):
try
:
...
...
Misc/NEWS
View file @
b7c057a1
...
...
@@ -262,6 +262,9 @@ Documentation
Tests
-----
- Issue #28666: Now test.test_support.rmtree is able to remove unwritable or
unreadable directories.
- Issue #23839: Various caches now are cleared before running every test file.
- Issue #27369: In test_pyexpat, avoid testing an error message detail that
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment