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
675b19f4
Commit
675b19f4
authored
Jan 04, 2008
by
Lars Gustäbel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #1735: TarFile.extractall() now correctly sets directory
permissions and times. (backport from r59712)
parent
9faf8830
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
4 deletions
+35
-4
Lib/tarfile.py
Lib/tarfile.py
+4
-4
Lib/test/test_tarfile.py
Lib/test/test_tarfile.py
+28
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tarfile.py
View file @
675b19f4
...
...
@@ -1525,11 +1525,11 @@ class TarFile(object):
# Set correct owner, mtime and filemode on directories.
for
tarinfo
in
directories
:
path
=
os
.
path
.
join
(
path
,
tarinfo
.
name
)
dir
path
=
os
.
path
.
join
(
path
,
tarinfo
.
name
)
try
:
self
.
chown
(
tarinfo
,
path
)
self
.
utime
(
tarinfo
,
path
)
self
.
chmod
(
tarinfo
,
path
)
self
.
chown
(
tarinfo
,
dir
path
)
self
.
utime
(
tarinfo
,
dir
path
)
self
.
chmod
(
tarinfo
,
dir
path
)
except
ExtractError
,
e
:
if
self
.
errorlevel
>
1
:
raise
...
...
Lib/test/test_tarfile.py
View file @
675b19f4
...
...
@@ -197,6 +197,34 @@ class ReadTest(BaseTest):
self
.
assert_
(
tarinfo
.
name
.
endswith
(
"/"
))
self
.
assert_
(
not
tarinfo
.
name
[:
-
1
].
endswith
(
"/"
))
def
test_extractall
(
self
):
# Test if extractall() correctly restores directory permissions
# and times (see issue1735).
if
sys
.
platform
==
"win32"
:
# Win32 has no support for utime() on directories or
# fine grained permissions.
return
fobj
=
StringIO
.
StringIO
()
tar
=
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
"w:"
)
for
name
in
(
"foo"
,
"foo/bar"
):
tarinfo
=
tarfile
.
TarInfo
(
name
)
tarinfo
.
type
=
tarfile
.
DIRTYPE
tarinfo
.
mtime
=
07606136617
tarinfo
.
mode
=
0755
tar
.
addfile
(
tarinfo
)
tar
.
close
()
fobj
.
seek
(
0
)
TEMPDIR
=
os
.
path
.
join
(
dirname
(),
"extract-test"
)
tar
=
tarfile
.
open
(
fileobj
=
fobj
)
tar
.
extractall
(
TEMPDIR
)
for
tarinfo
in
tar
.
getmembers
():
path
=
os
.
path
.
join
(
TEMPDIR
,
tarinfo
.
name
)
self
.
assertEqual
(
tarinfo
.
mode
,
os
.
stat
(
path
).
st_mode
&
0777
)
self
.
assertEqual
(
tarinfo
.
mtime
,
os
.
path
.
getmtime
(
path
))
tar
.
close
()
class
ReadStreamTest
(
ReadTest
):
sep
=
"|"
...
...
Misc/NEWS
View file @
675b19f4
...
...
@@ -53,6 +53,9 @@ Core and builtins
Library
-------
- Issue #1735: TarFile.extractall() now correctly sets directory permissions
and times.
- Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
- Issue #1700: Regular expression inline flags incorrectly handle certain
...
...
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