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
1c3fa18b
Kaydet (Commit)
1c3fa18b
authored
Haz 19, 2004
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
shutil.move() will raise an exception when trying to move a directory into
itself. Closes bug #919012 . Thanks Johannes Gijsbers.
üst
b46ed71d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
2 deletions
+24
-2
shutil.py
Lib/shutil.py
+6
-0
test_shutil.py
Lib/test/test_shutil.py
+14
-2
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/shutil.py
Dosyayı görüntüle @
1c3fa18b
...
@@ -8,6 +8,7 @@ import os
...
@@ -8,6 +8,7 @@ import os
import
sys
import
sys
import
stat
import
stat
import
exceptions
import
exceptions
from
os.path
import
abspath
__all__
=
[
"copyfileobj"
,
"copyfile"
,
"copymode"
,
"copystat"
,
"copy"
,
"copy2"
,
__all__
=
[
"copyfileobj"
,
"copyfile"
,
"copymode"
,
"copystat"
,
"copy"
,
"copy2"
,
"copytree"
,
"move"
,
"rmtree"
,
"Error"
]
"copytree"
,
"move"
,
"rmtree"
,
"Error"
]
...
@@ -164,8 +165,13 @@ def move(src, dst):
...
@@ -164,8 +165,13 @@ def move(src, dst):
os
.
rename
(
src
,
dst
)
os
.
rename
(
src
,
dst
)
except
OSError
:
except
OSError
:
if
os
.
path
.
isdir
(
src
):
if
os
.
path
.
isdir
(
src
):
if
destinsrc
(
src
,
dst
):
raise
Error
,
"Cannot move a directory '
%
s' into itself '
%
s'."
%
(
src
,
dst
)
copytree
(
src
,
dst
,
symlinks
=
True
)
copytree
(
src
,
dst
,
symlinks
=
True
)
rmtree
(
src
)
rmtree
(
src
)
else
:
else
:
copy2
(
src
,
dst
)
copy2
(
src
,
dst
)
os
.
unlink
(
src
)
os
.
unlink
(
src
)
def
destinsrc
(
src
,
dst
):
return
abspath
(
dst
)
.
startswith
(
abspath
(
src
))
Lib/test/test_shutil.py
Dosyayı görüntüle @
1c3fa18b
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
import
unittest
import
unittest
import
shutil
import
shutil
import
tempfile
import
tempfile
import
os
import
os.path
from
test
import
test_support
from
test
import
test_support
class
TestShutil
(
unittest
.
TestCase
):
class
TestShutil
(
unittest
.
TestCase
):
...
@@ -12,11 +14,21 @@ class TestShutil(unittest.TestCase):
...
@@ -12,11 +14,21 @@ class TestShutil(unittest.TestCase):
self
.
assertRaises
(
OSError
,
shutil
.
rmtree
,
filename
)
self
.
assertRaises
(
OSError
,
shutil
.
rmtree
,
filename
)
self
.
assertEqual
(
shutil
.
rmtree
(
filename
,
True
),
None
)
self
.
assertEqual
(
shutil
.
rmtree
(
filename
,
True
),
None
)
def
test_dont_move_dir_in_itself
(
self
):
src_dir
=
tempfile
.
mkdtemp
()
try
:
dst
=
os
.
path
.
join
(
src_dir
,
'foo'
)
self
.
assertRaises
(
shutil
.
Error
,
shutil
.
move
,
src_dir
,
dst
)
finally
:
try
:
os
.
rmdir
(
src_dir
)
except
:
pass
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
TestShutil
)
test_support
.
run_unittest
(
TestShutil
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
test_main
()
Misc/ACKS
Dosyayı görüntüle @
1c3fa18b
...
@@ -205,6 +205,7 @@ Christos Georgiou
...
@@ -205,6 +205,7 @@ Christos Georgiou
Ben Gertzfield
Ben Gertzfield
Dinu Gherman
Dinu Gherman
Jonathan Giddy
Jonathan Giddy
Johannes Gijsbers
Michael Gilfix
Michael Gilfix
Chris Gonnerman
Chris Gonnerman
David Goodger
David Goodger
...
...
Misc/NEWS
Dosyayı görüntüle @
1c3fa18b
...
@@ -340,6 +340,9 @@ Extension modules
...
@@ -340,6 +340,9 @@ Extension modules
Library
Library
-------
-------
- Bug #919012: shutil.move() will not try to move a directory into itself.
Thanks Johannes Gijsbers.
- Bug #934282: pydoc.stripid() is now case-insensitive. Thanks Robin Becker.
- Bug #934282: pydoc.stripid() is now case-insensitive. Thanks Robin Becker.
- Bug #823209: cmath.log() now takes an optional base argument so that its
- Bug #823209: cmath.log() now takes an optional base argument so that its
...
...
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