]> granicus.if.org Git - python/commitdiff
package: replace open(fn, 'w').close() by open(fn, 'wb').close()
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 19 May 2011 13:52:59 +0000 (15:52 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 19 May 2011 13:52:59 +0000 (15:52 +0200)
We don't need to open the files in text mode just to create them (or update
their modification time).

Lib/packaging/command/install_distinfo.py
Lib/packaging/tests/test_command_build_py.py
Lib/packaging/tests/test_database.py
Lib/packaging/tests/test_install.py
Lib/packaging/util.py

index a25a15a2bbcac1c79a3e702942f12226eae1f282..db49236b96a939af27037a83b315f871234f48f2 100644 (file)
@@ -98,7 +98,7 @@ class install_distinfo(Command):
             if self.requested:
                 requested_path = os.path.join(self.distinfo_dir, 'REQUESTED')
                 logger.info('creating %s', requested_path)
-                open(requested_path, 'w').close()
+                open(requested_path, 'wb').close()
                 self.outputs.append(requested_path)
 
 
index 9b40e6d9b23ca5f37157dafc12a4325869f1b729..3c5630b23f71c6669d59e28d3d48c4fdab94d117 100644 (file)
@@ -72,10 +72,10 @@ class BuildPyTestCase(support.TempdirManager,
         sources = self.mkdtemp()
         pkg = os.path.join(sources, '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")
         os.mkdir(testdir)
-        open(os.path.join(testdir, "testfile"), "w").close()
+        open(os.path.join(testdir, "testfile"), "wb").close()
 
         os.chdir(sources)
         old_stdout = sys.stdout
index c8d941527eaa4ffa1355c4b997d73666371d3b8a..251181aba0d594bd7e9df061df493f6e2278aea6 100644 (file)
@@ -133,7 +133,7 @@ class TestDistribution(CommonDistributionTests, unittest.TestCase):
     def tearDown(self):
         for distinfo_dir in self.dirs:
             record_file = os.path.join(distinfo_dir, 'RECORD')
-            open(record_file, 'w').close()
+            open(record_file, 'wb').close()
         super(TestDistribution, self).tearDown()
 
     def test_instantiation(self):
index 8aae4ac29ca4814b48bdcac5cf31825d33d7b9f7..7bdee943afc7d8023ee72a5f9312a1484a52752f 100644 (file)
@@ -227,7 +227,7 @@ class TestInstall(LoggingCatcher, TempdirManager, unittest.TestCase):
         newpath = self.mkdtemp()
         files = [os.path.join(path, str(x)) for x in range(1, 20)]
         for f in files:
-            open(f, 'a+').close()
+            open(f, 'ab+').close()
         output = [o for o in install._move_files(files, newpath)]
 
         # check that output return the list of old/new places
index 348e3cd14a74ffe877d2ecf037f1722ba6d7023f..058f13e334e02ff399fbd37b44a14d47cdc41077 100644 (file)
@@ -1201,7 +1201,7 @@ def egginfo_to_distinfo(record_file, installer=_DEFAULT_INSTALLER,
     if requested:
         requested_path = distinfo['requested_path']
         logger.info('creating %s', requested_path)
-        open(requested_path, 'w').close()
+        open(requested_path, 'wb').close()
         distinfo['installed'].append(requested_path)
 
     record_path = distinfo['record_path']