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
bc3b0608
Commit
bc3b0608
authored
Aug 24, 2005
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1262036: Make tarfile name absolute. Fixes #1257255.
Will backport to 2.4.
parent
94ac1975
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
20 deletions
+9
-20
Lib/tarfile.py
Lib/tarfile.py
+7
-20
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/tarfile.py
View file @
bc3b0608
...
...
@@ -849,7 +849,7 @@ class TarFile(object):
can be determined, `mode' is overridden by `fileobj's mode.
`fileobj' is not closed, when TarFile is closed.
"""
self
.
name
=
name
self
.
name
=
os
.
path
.
abspath
(
name
)
if
len
(
mode
)
>
1
or
mode
not
in
"raw"
:
raise
ValueError
,
"mode must be 'r', 'a' or 'w'"
...
...
@@ -861,7 +861,7 @@ class TarFile(object):
self
.
_extfileobj
=
False
else
:
if
self
.
name
is
None
and
hasattr
(
fileobj
,
"name"
):
self
.
name
=
fileobj
.
name
self
.
name
=
os
.
path
.
abspath
(
fileobj
.
name
)
if
hasattr
(
fileobj
,
"mode"
):
self
.
mode
=
fileobj
.
mode
self
.
_extfileobj
=
True
...
...
@@ -998,22 +998,18 @@ class TarFile(object):
raise
CompressionError
,
"gzip module is not available"
pre
,
ext
=
os
.
path
.
splitext
(
name
)
pre
=
os
.
path
.
basename
(
pre
)
if
ext
==
".tgz"
:
ext
=
".tar"
if
ext
==
".gz"
:
ext
=
""
tarname
=
pre
+
ext
tarname
=
os
.
path
.
basename
(
pre
+
ext
)
if
fileobj
is
None
:
fileobj
=
file
(
name
,
mode
+
"b"
)
if
mode
!=
"r"
:
name
=
tarname
try
:
t
=
cls
.
taropen
(
tar
name
,
mode
,
gzip
.
GzipFile
(
name
,
mode
,
compresslevel
,
fileobj
)
t
=
cls
.
taropen
(
name
,
mode
,
gzip
.
GzipFile
(
tar
name
,
mode
,
compresslevel
,
fileobj
)
)
except
IOError
:
raise
ReadError
,
"not a gzip file"
...
...
@@ -1033,19 +1029,11 @@ class TarFile(object):
except
ImportError
:
raise
CompressionError
,
"bz2 module is not available"
pre
,
ext
=
os
.
path
.
splitext
(
name
)
pre
=
os
.
path
.
basename
(
pre
)
if
ext
==
".tbz2"
:
ext
=
".tar"
if
ext
==
".bz2"
:
ext
=
""
tarname
=
pre
+
ext
if
fileobj
is
not
None
:
raise
ValueError
,
"no support for external file objects"
try
:
t
=
cls
.
taropen
(
tar
name
,
mode
,
bz2
.
BZ2File
(
name
,
mode
,
compresslevel
=
compresslevel
))
t
=
cls
.
taropen
(
name
,
mode
,
bz2
.
BZ2File
(
name
,
mode
,
compresslevel
=
compresslevel
))
except
IOError
:
raise
ReadError
,
"not a bzip2 file"
t
.
_extfileobj
=
False
...
...
@@ -1250,8 +1238,7 @@ class TarFile(object):
arcname
=
name
# Skip if somebody tries to archive the archive...
if
self
.
name
is
not
None
\
and
os
.
path
.
abspath
(
name
)
==
os
.
path
.
abspath
(
self
.
name
):
if
self
.
name
is
not
None
and
os
.
path
.
samefile
(
name
,
self
.
name
):
self
.
_dbg
(
2
,
"tarfile: Skipped %r"
%
name
)
return
...
...
Misc/NEWS
View file @
bc3b0608
...
...
@@ -188,6 +188,8 @@ Extension Modules
Library
-------
-
Patch
#
1262036
:
Make
tarfile
name
absolute
.
Fixes
#
1257255.
-
Patch
#
827386
:
Support
absolute
source
paths
in
msvccompiler
.
py
.
-
Patch
#
1105730
:
Apply
the
new
implementation
of
commonprefix
in
posixpath
...
...
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