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
136148e9
Commit
136148e9
authored
May 06, 2011
by
Ronald Oussoren
Browse files
Options
Browse Files
Download
Plain Diff
merge from 3.2
parents
f804f3a5
78349b06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
Lib/shutil.py
Lib/shutil.py
+7
-1
Lib/test/test_shutil.py
Lib/test/test_shutil.py
+18
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/shutil.py
View file @
136148e9
...
...
@@ -311,12 +311,18 @@ def move(src, dst):
"""
real_dst
=
dst
if
os
.
path
.
isdir
(
dst
):
if
_samefile
(
src
,
dst
):
# We might be on a case insensitive filesystem,
# perform the rename anyway.
os
.
rename
(
src
,
dst
)
return
real_dst
=
os
.
path
.
join
(
dst
,
_basename
(
src
))
if
os
.
path
.
exists
(
real_dst
):
raise
Error
(
"Destination path '%s' already exists"
%
real_dst
)
try
:
os
.
rename
(
src
,
real_dst
)
except
OSError
:
except
OSError
as
exc
:
if
os
.
path
.
isdir
(
src
):
if
_destinsrc
(
src
,
dst
):
raise
Error
(
"Cannot move a directory '%s' into itself '%s'."
%
(
src
,
dst
))
...
...
Lib/test/test_shutil.py
View file @
136148e9
...
...
@@ -951,6 +951,24 @@ class TestCopyFile(unittest.TestCase):
self
.
assertTrue
(
srcfile
.
_exited_with
[
0
]
is
None
)
self
.
assertTrue
(
srcfile
.
_raised
)
def
test_move_dir_caseinsensitive
(
self
):
# Renames a folder to the same name
# but a different case.
self
.
src_dir
=
tempfile
.
mkdtemp
()
dst_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
self
.
src_dir
),
os
.
path
.
basename
(
self
.
src_dir
).
upper
())
self
.
assertNotEqual
(
self
.
src_dir
,
dst_dir
)
try
:
shutil
.
move
(
self
.
src_dir
,
dst_dir
)
self
.
assertTrue
(
os
.
path
.
isdir
(
dst_dir
))
finally
:
if
os
.
path
.
exists
(
dst_dir
):
os
.
rmdir
(
dst_dir
)
def
test_main
():
support
.
run_unittest
(
TestShutil
,
TestMove
,
TestCopyFile
)
...
...
Misc/NEWS
View file @
136148e9
...
...
@@ -140,6 +140,10 @@ Core and Builtins
Library
-------
- Issue #10684: shutil.move used to delete a folder on case insensitive
filesystems when the source and destination name where the same except
for the case.
- Issue #11647: objects created using contextlib.contextmanager now support
more than one call to the function when used as a decorator. Initial patch
by Ysj Ray.
...
...
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