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
baf75713
Commit
baf75713
authored
May 10, 2012
by
Ned Deily
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #14662: Prevent shutil failures on OS X when destination does not
support chflag operations. (Patch by Hynek Schlawack)
parent
569d0875
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
Lib/shutil.py
Lib/shutil.py
+4
-2
Lib/test/test_shutil.py
Lib/test/test_shutil.py
+29
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/shutil.py
View file @
baf75713
...
...
@@ -160,8 +160,10 @@ def copystat(src, dst, symlinks=False):
try
:
chflags_func
(
dst
,
st
.
st_flags
)
except
OSError
as
why
:
if
(
not
hasattr
(
errno
,
'EOPNOTSUPP'
)
or
why
.
errno
!=
errno
.
EOPNOTSUPP
):
for
err
in
'EOPNOTSUPP'
,
'ENOTSUP'
:
if
hasattr
(
errno
,
err
)
and
why
.
errno
==
getattr
(
errno
,
err
):
break
else
:
raise
def
copy
(
src
,
dst
,
symlinks
=
False
):
...
...
Lib/test/test_shutil.py
View file @
baf75713
...
...
@@ -282,6 +282,35 @@ class TestShutil(unittest.TestCase):
self
.
assertTrue
(
abs
(
os
.
stat
(
src
).
st_mtime
-
os
.
stat
(
dst
).
st_mtime
)
<
00000.1
)
@
unittest
.
skipUnless
(
hasattr
(
os
,
'chflags'
)
and
hasattr
(
errno
,
'EOPNOTSUPP'
)
and
hasattr
(
errno
,
'ENOTSUP'
),
"requires os.chflags, EOPNOTSUPP & ENOTSUP"
)
def
test_copystat_handles_harmless_chflags_errors
(
self
):
tmpdir
=
self
.
mkdtemp
()
file1
=
os
.
path
.
join
(
tmpdir
,
'file1'
)
file2
=
os
.
path
.
join
(
tmpdir
,
'file2'
)
write_file
(
file1
,
'xxx'
)
write_file
(
file2
,
'xxx'
)
def
make_chflags_raiser
(
err
):
ex
=
OSError
()
def
_chflags_raiser
(
path
,
flags
):
ex
.
errno
=
err
raise
ex
return
_chflags_raiser
old_chflags
=
os
.
chflags
try
:
for
err
in
errno
.
EOPNOTSUPP
,
errno
.
ENOTSUP
:
os
.
chflags
=
make_chflags_raiser
(
err
)
shutil
.
copystat
(
file1
,
file2
)
# assert others errors break it
os
.
chflags
=
make_chflags_raiser
(
errno
.
EOPNOTSUPP
+
errno
.
ENOTSUP
)
self
.
assertRaises
(
OSError
,
shutil
.
copystat
,
file1
,
file2
)
finally
:
os
.
chflags
=
old_chflags
@
support
.
skip_unless_symlink
def
test_copy_symlinks
(
self
):
tmp_dir
=
self
.
mkdtemp
()
...
...
Misc/NEWS
View file @
baf75713
...
...
@@ -23,6 +23,9 @@ Core and Builtins
Library
-------
- Issue #14662: Prevent shutil failures on OS X when destination does not
support chflag operations. Patch by Hynek Schlawack.
- Issue #14157: Fix time.strptime failing without a year on February 29th.
Patch by Hynek Schlawack.
...
...
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