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
6cef076b
Commit
6cef076b
authored
May 25, 2007
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove direct call's to file's constructor and replace them with calls to
open() as ths is considered best practice.
parent
cf99b659
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
Lib/tarfile.py
Lib/tarfile.py
+5
-4
Lib/test/test_zipfile.py
Lib/test/test_zipfile.py
+1
-1
No files found.
Lib/tarfile.py
View file @
6cef076b
...
...
@@ -1490,7 +1490,7 @@ class TarFile(object):
# Create nonexistent files in append mode.
self.mode = "
w
"
self._mode = "
wb
"
fileobj =
file
(name, self._mode)
fileobj =
bltn_open
(name, self._mode)
self._extfileobj = False
else:
if name is None and hasattr(fileobj, "
name
"):
...
...
@@ -1667,7 +1667,7 @@ class TarFile(object):
raise CompressionError("
gzip
module
is
not
available
")
if fileobj is None:
fileobj =
file
(name, mode + "b")
fileobj =
bltn_open
(name, mode + "b")
try:
t = cls.taropen(name, mode,
...
...
@@ -1928,7 +1928,7 @@ class TarFile(object):
# Append the tar header and data to the archive.
if tarinfo.isreg():
f =
file
(name, "rb")
f =
bltn_open
(name, "rb")
self.addfile(tarinfo, f)
f.close()
...
...
@@ -2139,7 +2139,7 @@ class TarFile(object):
"""Make a file called targetpath.
"""
source = self.extractfile(tarinfo)
target =
file
(targetpath, "
wb
")
target =
bltn_open
(targetpath, "
wb
")
copyfileobj(source, target)
source.close()
target.close()
...
...
@@ -2484,4 +2484,5 @@ def is_tarfile(name):
except TarError:
return False
bltn_open = open
open = TarFile.open
Lib/test/test_zipfile.py
View file @
6cef076b
...
...
@@ -712,7 +712,7 @@ class UniversalNewlineTests(unittest.TestCase):
for
n
,
s
in
enumerate
(
self
.
seps
):
self
.
arcdata
[
s
]
=
s
.
join
(
self
.
line_gen
)
+
s
self
.
arcfiles
[
s
]
=
'%s-%d'
%
(
TESTFN
,
n
)
file
(
self
.
arcfiles
[
s
],
"wb"
).
write
(
self
.
arcdata
[
s
])
open
(
self
.
arcfiles
[
s
],
"wb"
).
write
(
self
.
arcdata
[
s
])
def
makeTestArchive
(
self
,
f
,
compression
):
# Create the ZIP archive
...
...
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