package: replace open(fn, 'w').close() by open(fn, 'wb').close()

We don't need to open the files in text mode just to create them (or update
their modification time).
This commit is contained in:
Victor Stinner 2011-05-19 15:52:59 +02:00
parent 21a9c748aa
commit 4c9706bd27
5 changed files with 6 additions and 6 deletions

View File

@ -98,7 +98,7 @@ class install_distinfo(Command):
if self.requested: if self.requested:
requested_path = os.path.join(self.distinfo_dir, 'REQUESTED') requested_path = os.path.join(self.distinfo_dir, 'REQUESTED')
logger.info('creating %s', requested_path) logger.info('creating %s', requested_path)
open(requested_path, 'w').close() open(requested_path, 'wb').close()
self.outputs.append(requested_path) self.outputs.append(requested_path)

View File

@ -72,10 +72,10 @@ class BuildPyTestCase(support.TempdirManager,
sources = self.mkdtemp() sources = self.mkdtemp()
pkg = os.path.join(sources, 'pkg') pkg = os.path.join(sources, 'pkg')
os.mkdir(pkg) os.mkdir(pkg)
open(os.path.join(pkg, "__init__.py"), "w").close() open(os.path.join(pkg, "__init__.py"), "wb").close()
testdir = os.path.join(pkg, "doc") testdir = os.path.join(pkg, "doc")
os.mkdir(testdir) os.mkdir(testdir)
open(os.path.join(testdir, "testfile"), "w").close() open(os.path.join(testdir, "testfile"), "wb").close()
os.chdir(sources) os.chdir(sources)
old_stdout = sys.stdout old_stdout = sys.stdout

View File

@ -133,7 +133,7 @@ class TestDistribution(CommonDistributionTests, unittest.TestCase):
def tearDown(self): def tearDown(self):
for distinfo_dir in self.dirs: for distinfo_dir in self.dirs:
record_file = os.path.join(distinfo_dir, 'RECORD') record_file = os.path.join(distinfo_dir, 'RECORD')
open(record_file, 'w').close() open(record_file, 'wb').close()
super(TestDistribution, self).tearDown() super(TestDistribution, self).tearDown()
def test_instantiation(self): def test_instantiation(self):

View File

@ -227,7 +227,7 @@ class TestInstall(LoggingCatcher, TempdirManager, unittest.TestCase):
newpath = self.mkdtemp() newpath = self.mkdtemp()
files = [os.path.join(path, str(x)) for x in range(1, 20)] files = [os.path.join(path, str(x)) for x in range(1, 20)]
for f in files: for f in files:
open(f, 'a+').close() open(f, 'ab+').close()
output = [o for o in install._move_files(files, newpath)] output = [o for o in install._move_files(files, newpath)]
# check that output return the list of old/new places # check that output return the list of old/new places

View File

@ -1201,7 +1201,7 @@ def egginfo_to_distinfo(record_file, installer=_DEFAULT_INSTALLER,
if requested: if requested:
requested_path = distinfo['requested_path'] requested_path = distinfo['requested_path']
logger.info('creating %s', requested_path) logger.info('creating %s', requested_path)
open(requested_path, 'w').close() open(requested_path, 'wb').close()
distinfo['installed'].append(requested_path) distinfo['installed'].append(requested_path)
record_path = distinfo['record_path'] record_path = distinfo['record_path']