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
b1a54a35
Commit
b1a54a35
authored
May 27, 2008
by
Lars Gustäbel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not close external file objects passed to tarfile.open(mode='w:bz2')
when the TarFile is closed.
parent
0902cac4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
Lib/tarfile.py
Lib/tarfile.py
+0
-1
Lib/test/test_tarfile.py
Lib/test/test_tarfile.py
+14
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tarfile.py
View file @
b1a54a35
...
...
@@ -692,7 +692,6 @@ class _BZ2Proxy(object):
if
self
.
mode
==
"w"
:
raw
=
self
.
bz2obj
.
flush
()
self
.
fileobj
.
write
(
raw
)
self
.
fileobj
.
close
()
# class _BZ2Proxy
#------------------------
...
...
Lib/test/test_tarfile.py
View file @
b1a54a35
...
...
@@ -529,7 +529,19 @@ class PaxReadTest(LongnameTest):
self
.
assertEqual
(
float
(
tarinfo
.
pax_headers
[
"ctime"
]),
1041808783.0
)
class
WriteTest
(
unittest
.
TestCase
):
class
WriteTestBase
(
unittest
.
TestCase
):
# Put all write tests in here that are supposed to be tested
# in all possible mode combinations.
def
test_fileobj_no_close
(
self
):
fobj
=
StringIO
.
StringIO
()
tar
=
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
tar
.
addfile
(
tarfile
.
TarInfo
(
"foo"
))
tar
.
close
()
self
.
assert_
(
fobj
.
closed
is
False
,
"external fileobjs must never closed"
)
class
WriteTest
(
WriteTestBase
):
mode
=
"w:"
...
...
@@ -652,7 +664,7 @@ class WriteTest(unittest.TestCase):
shutil
.
rmtree
(
tempdir
)
class
StreamWriteTest
(
unittest
.
TestC
ase
):
class
StreamWriteTest
(
WriteTestB
ase
):
mode
=
"w|"
...
...
Misc/NEWS
View file @
b1a54a35
...
...
@@ -63,6 +63,9 @@ Extension Modules
Library
-------
- Do not close external file objects passed to tarfile.open(mode='w:bz2')
when the TarFile is closed.
- Issue #2959: For consistency with other file-like objects, gzip's
GzipFile.close() can now be called multiple times without raising
an exception.
...
...
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