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
52353983
Kaydet (Commit)
52353983
authored
Ock 20, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#1669: don't allow shutil.rmtree() to be called on a symlink.
üst
56112895
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
12 deletions
+43
-12
shutil.rst
Doc/library/shutil.rst
+18
-12
shutil.py
Lib/shutil.py
+8
-0
test_shutil.py
Lib/test/test_shutil.py
+14
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/shutil.rst
Dosyayı görüntüle @
52353983
...
...
@@ -101,18 +101,24 @@ copying and removal. For operations on individual files, see also the
.. index:: single: directory; deleting
Delete an entire directory tree (*path* must point to a directory). If
*ignore_errors* is true, errors resulting from failed removals will be ignored;
if false or omitted, such errors are handled by calling a handler specified by
*onerror* or, if that is omitted, they raise an exception.
If *onerror* is provided, it must be a callable that accepts three parameters:
*function*, *path*, and *excinfo*. The first parameter, *function*, is the
function which raised the exception; it will be :func:`os.listdir`,
:func:`os.remove` or :func:`os.rmdir`. The second parameter, *path*, will be
the path name passed to *function*. The third parameter, *excinfo*, will be the
exception information return by :func:`sys.exc_info`. Exceptions raised by
*onerror* will not be caught.
Delete an entire directory tree; *path* must point to a directory (but not a
symbolic link to a directory). If *ignore_errors* is true, errors resulting
from failed removals will be ignored; if false or omitted, such errors are
handled by calling a handler specified by *onerror* or, if that is omitted,
they raise an exception.
If *onerror* is provided, it must be a callable that accepts three
parameters: *function*, *path*, and *excinfo*. The first parameter,
*function*, is the function which raised the exception; it will be
:func:`os.path.islink`, :func:`os.listdir`, :func:`os.remove` or
:func:`os.rmdir`. The second parameter, *path*, will be the path name passed
to *function*. The third parameter, *excinfo*, will be the exception
information return by :func:`sys.exc_info`. Exceptions raised by *onerror*
will not be caught.
.. versionchanged:: 2.6
Explicitly check for *path* being a symbolic link and raise :exc:`OSError`
in that case.
.. function:: move(src, dst)
...
...
Lib/shutil.py
Dosyayı görüntüle @
52353983
...
...
@@ -156,6 +156,14 @@ def rmtree(path, ignore_errors=False, onerror=None):
elif
onerror
is
None
:
def
onerror
(
*
args
):
raise
try
:
if
os
.
path
.
islink
(
path
):
# symlinks to directories are forbidden, see bug #1669
raise
OSError
(
"Cannot call rmtree on a symbolic link"
)
except
OSError
:
onerror
(
os
.
path
.
islink
,
path
,
sys
.
exc_info
())
# can't continue even if onerror hook returns
return
names
=
[]
try
:
names
=
os
.
listdir
(
path
)
...
...
Lib/test/test_shutil.py
Dosyayı görüntüle @
52353983
...
...
@@ -149,6 +149,20 @@ class TestShutil(unittest.TestCase):
except
OSError
:
pass
def
test_rmtree_on_symlink
(
self
):
# bug 1669.
os
.
mkdir
(
TESTFN
)
try
:
src
=
os
.
path
.
join
(
TESTFN
,
'cheese'
)
dst
=
os
.
path
.
join
(
TESTFN
,
'shop'
)
os
.
mkdir
(
src
)
os
.
symlink
(
src
,
dst
)
self
.
assertRaises
(
OSError
,
shutil
.
rmtree
,
dst
)
finally
:
shutil
.
rmtree
(
TESTFN
,
ignore_errors
=
True
)
def
test_main
():
test_support
.
run_unittest
(
TestShutil
)
...
...
Misc/NEWS
Dosyayı görüntüle @
52353983
...
...
@@ -369,6 +369,9 @@ Core and builtins
Library
-------
- #1669: don'
t
allow
shutil
.
rmtree
()
to
be
called
on
a
symlink
to
a
directory
.
-
#
1664522
:
in
urllib
,
don
't read non-existing directories in ftp mode,
returning a 0-byte file -- raise an IOError instead.
...
...
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