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
d0f6e0a6
Commit
d0f6e0a6
authored
Jun 29, 2012
by
Hynek Schlawack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for all used fd-based functions in shutil.rmdir, closes #15218
parent
0b50bf3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
Lib/shutil.py
Lib/shutil.py
+4
-2
Lib/test/test_shutil.py
Lib/test/test_shutil.py
+5
-1
No files found.
Lib/shutil.py
View file @
d0f6e0a6
...
...
@@ -405,8 +405,10 @@ def _rmtree_safe_fd(topfd, path, onerror):
except
os
.
error
:
onerror
(
os
.
unlink
,
fullname
,
sys
.
exc_info
())
_use_fd_functions
=
(
os
.
unlink
in
os
.
supports_dir_fd
and
os
.
open
in
os
.
supports_dir_fd
)
_use_fd_functions
=
({
os
.
open
,
os
.
stat
,
os
.
unlink
,
os
.
rmdir
}
<=
os
.
supports_dir_fd
and
os
.
listdir
in
os
.
supports_fd
and
os
.
stat
in
os
.
supports_follow_symlinks
)
def
rmtree
(
path
,
ignore_errors
=
False
,
onerror
=
None
):
"""Recursively delete a directory tree.
...
...
Lib/test/test_shutil.py
View file @
d0f6e0a6
...
...
@@ -524,7 +524,11 @@ class TestShutil(unittest.TestCase):
self
.
assertFalse
(
os
.
path
.
islink
(
dst
))
def
test_rmtree_uses_safe_fd_version_if_available
(
self
):
if
os
.
unlink
in
os
.
supports_dir_fd
and
os
.
open
in
os
.
supports_dir_fd
:
_use_fd_functions
=
({
os
.
open
,
os
.
stat
,
os
.
unlink
,
os
.
rmdir
}
<=
os
.
supports_dir_fd
and
os
.
listdir
in
os
.
supports_fd
and
os
.
stat
in
os
.
supports_follow_symlinks
)
if
_use_fd_functions
:
self
.
assertTrue
(
shutil
.
_use_fd_functions
)
self
.
assertTrue
(
shutil
.
rmtree
.
avoids_symlink_attacks
)
tmp_dir
=
self
.
mkdtemp
()
...
...
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