Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
abb755db
Kaydet (Commit)
abb755db
authored
Haz 28, 2012
tarafından
Eric V. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge.
üst
b1095154
a75cd1ce
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
shutil.py
Lib/shutil.py
+2
-2
test_shutil.py
Lib/test/test_shutil.py
+33
-1
No files found.
Lib/shutil.py
Dosyayı görüntüle @
abb755db
...
...
@@ -380,7 +380,7 @@ def _rmtree_safe_fd(topfd, path, onerror):
for
name
in
names
:
fullname
=
os
.
path
.
join
(
path
,
name
)
try
:
orig_st
=
os
.
stat
(
name
,
dir_fd
=
topfd
)
orig_st
=
os
.
stat
(
name
,
dir_fd
=
topfd
,
follow_symlinks
=
False
)
mode
=
orig_st
.
st_mode
except
os
.
error
:
mode
=
0
...
...
@@ -445,7 +445,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
if
(
stat
.
S_ISDIR
(
orig_st
.
st_mode
)
and
os
.
path
.
samestat
(
orig_st
,
os
.
fstat
(
fd
))):
_rmtree_safe_fd
(
fd
,
path
,
onerror
)
el
if
(
stat
.
S_ISREG
(
orig_st
.
st_mode
))
:
el
se
:
raise
NotADirectoryError
(
20
,
"Not a directory: '{}'"
.
format
(
path
))
finally
:
...
...
Lib/test/test_shutil.py
Dosyayı görüntüle @
abb755db
...
...
@@ -117,6 +117,38 @@ class TestShutil(unittest.TestCase):
self
.
assertIsInstance
(
victim
,
bytes
)
shutil
.
rmtree
(
victim
)
@support.skip_unless_symlink
def
test_rmtree_fails_on_symlink
(
self
):
tmp
=
self
.
mkdtemp
()
dir_
=
os
.
path
.
join
(
tmp
,
'dir'
)
os
.
mkdir
(
dir_
)
link
=
os
.
path
.
join
(
tmp
,
'link'
)
os
.
symlink
(
dir_
,
link
)
self
.
assertRaises
(
OSError
,
shutil
.
rmtree
,
link
)
self
.
assertTrue
(
os
.
path
.
exists
(
dir_
))
@support.skip_unless_symlink
def
test_rmtree_works_on_symlinks
(
self
):
tmp
=
self
.
mkdtemp
()
dir1
=
os
.
path
.
join
(
tmp
,
'dir1'
)
dir2
=
os
.
path
.
join
(
dir1
,
'dir2'
)
dir3
=
os
.
path
.
join
(
tmp
,
'dir3'
)
for
d
in
dir1
,
dir2
,
dir3
:
os
.
mkdir
(
d
)
file1
=
os
.
path
.
join
(
tmp
,
'file1'
)
write_file
(
file1
,
'foo'
)
link1
=
os
.
path
.
join
(
dir1
,
'link1'
)
os
.
symlink
(
dir2
,
link1
)
link2
=
os
.
path
.
join
(
dir1
,
'link2'
)
os
.
symlink
(
dir3
,
link2
)
link3
=
os
.
path
.
join
(
dir1
,
'link3'
)
os
.
symlink
(
file1
,
link3
)
# make sure symlinks are removed but not followed
shutil
.
rmtree
(
dir1
)
self
.
assertFalse
(
os
.
path
.
exists
(
dir1
))
self
.
assertTrue
(
os
.
path
.
exists
(
dir3
))
self
.
assertTrue
(
os
.
path
.
exists
(
file1
))
def
test_rmtree_errors
(
self
):
# filename is guaranteed not to exist
filename
=
tempfile
.
mktemp
()
...
...
@@ -184,7 +216,7 @@ class TestShutil(unittest.TestCase):
def
test_rmtree_does_not_choke_on_failing_lstat
(
self
):
try
:
orig_lstat
=
os
.
lstat
def
raiser
(
fn
):
def
raiser
(
fn
,
*
args
,
**
kwargs
):
if
fn
!=
TESTFN
:
raise
OSError
()
else
:
...
...
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