Remove workarounds for versions of Python before 2.7
authorevab.u-szeged@partner.samsung.com <evab.u-szeged@partner.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Oct 2014 10:14:36 +0000 (10:14 +0000)
committerevab.u-szeged@partner.samsung.com <evab.u-szeged@partner.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Oct 2014 10:14:36 +0000 (10:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137338

Reviewed by Csaba Osztrogon√°c.

* Scripts/webkitpy/common/system/autoinstall.py:
(AutoInstaller._extract_targz):
(AutoInstaller._unzip):
(AutoInstaller): Deleted.
(AutoInstaller._extract_all): Deleted.
* Scripts/webkitpy/common/webkitunittest.py:
(TestCase.setUp): Deleted.
* Scripts/webkitpy/layout_tests/models/test_configuration.py:
(TestConfigurationConverter.collapse_macros):
(TestConfigurationConverter.to_specifiers_list.try_collapsing):
(TestConfigurationConverter.to_specifiers_list.try_abbreviating):
(TestConfigurationConverter):
(TestConfigurationConverter.combinations): Deleted.
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
* Scripts/webkitpy/port/base.py:
* Scripts/webkitpy/port/driver.py:
(ContentBlock.__init__):
* Scripts/webkitpy/port/server_process.py:
(ServerProcess._reset):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174264 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/autoinstall.py
Tools/Scripts/webkitpy/common/webkitunittest.py
Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py
Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py
Tools/Scripts/webkitpy/port/base.py
Tools/Scripts/webkitpy/port/driver.py
Tools/Scripts/webkitpy/port/server_process.py

index af9da2d..ed839e0 100644 (file)
@@ -1,5 +1,32 @@
 2014-10-03  Eva Balazsfalvi  <evab.u-szeged@partner.samsung.com>
 
+        Remove workarounds for versions of Python before 2.7
+        https://bugs.webkit.org/show_bug.cgi?id=137338
+
+        Reviewed by Csaba Osztrogon√°c.
+
+        * Scripts/webkitpy/common/system/autoinstall.py:
+        (AutoInstaller._extract_targz):
+        (AutoInstaller._unzip):
+        (AutoInstaller): Deleted.
+        (AutoInstaller._extract_all): Deleted.
+        * Scripts/webkitpy/common/webkitunittest.py:
+        (TestCase.setUp): Deleted.
+        * Scripts/webkitpy/layout_tests/models/test_configuration.py:
+        (TestConfigurationConverter.collapse_macros):
+        (TestConfigurationConverter.to_specifiers_list.try_collapsing):
+        (TestConfigurationConverter.to_specifiers_list.try_abbreviating):
+        (TestConfigurationConverter):
+        (TestConfigurationConverter.combinations): Deleted.
+        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
+        * Scripts/webkitpy/port/base.py:
+        * Scripts/webkitpy/port/driver.py:
+        (ContentBlock.__init__):
+        * Scripts/webkitpy/port/server_process.py:
+        (ServerProcess._reset):
+
+2014-10-03  Eva Balazsfalvi  <evab.u-szeged@partner.samsung.com>
+
         Remove autoinstaller workaround for python 2.6
         https://bugs.webkit.org/show_bug.cgi?id=137343
 
index 4bb0558..031a3e1 100644 (file)
@@ -218,34 +218,6 @@ class AutoInstaller(object):
 
         return target_path
 
-    # This is a replacement for ZipFile.extractall(), which is
-    # available in Python 2.6 but not in earlier versions.
-    # NOTE: The version in 2.6.1 (which shipped on Snow Leopard) is broken!
-    def _extract_all(self, zip_file, target_dir):
-        for name in zip_file.namelist():
-            path = os.path.join(target_dir, name)
-            if not os.path.basename(path):
-                # Then the path ends in a slash, so it is a directory.
-                os.makedirs(path)
-                continue
-
-            try:
-                # We open this file w/o encoding, as we're reading/writing
-                # the raw byte-stream from the zip file.
-                outfile = open(path, 'wb')
-            except IOError:
-                # Not all zip files seem to list the directories explicitly,
-                # so try again after creating the containing directory.
-                _log.debug("Got IOError: retrying after creating directory...")
-                dirname = os.path.dirname(path)
-                os.makedirs(dirname)
-                outfile = open(path, 'wb')
-
-            try:
-                outfile.write(zip_file.read(name))
-            finally:
-                outfile.close()
-
     def _unzip(self, path, scratch_dir):
         # zipfile.extractall() extracts to a path without the trailing ".zip".
         target_basename = os.path.basename(path[:-len(".zip")])
@@ -260,7 +232,7 @@ class AutoInstaller(object):
             raise Exception(message)
 
         try:
-            self._extract_all(zip_file, scratch_dir)
+            zip_file.extractall(zip_file, scratch_dir)
         finally:
             zip_file.close()
 
index 7b650a1..1902e71 100644 (file)
@@ -33,11 +33,6 @@ import unittest
 
 
 class TestCase(unittest.TestCase):
-    def setUp(self):
-        # For versions of Python before 2.7.
-        if not 'assertRaisesRegexp' in dir(self):
-            self.assertRaisesRegexp = self._assertRaisesRegexp
-
     def _assertRaisesRegexp(self, expected_exception, regex_message, callable, *args):
         try:
             callable(*args)
index 95d0f2b..c07d861 100644 (file)
@@ -26,6 +26,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import itertools
 
 class TestConfiguration(object):
     def __init__(self, version, architecture, build_type):
@@ -168,7 +169,7 @@ class TestConfigurationConverter(object):
             if len(macro) == 1:
                 continue
 
-            for combination in cls.combinations(specifiers_list, len(macro)):
+            for combination in itertools.combinations(specifiers_list, len(macro)):
                 if cls.symmetric_difference(combination) == set(macro):
                     for item in combination:
                         specifiers_list.remove(item)
@@ -192,30 +193,6 @@ class TestConfigurationConverter(object):
         for macro_specifier, macro in macros_dict.items():
             collapse_individual_specifier_set(macro_specifier, macro)
 
-    # FIXME: itertools.combinations in buggy in Python 2.6.1 (the version that ships on SL).
-    # It seems to be okay in 2.6.5 or later; until then, this is the implementation given
-    # in http://docs.python.org/library/itertools.html (from 2.7).
-    @staticmethod
-    def combinations(iterable, r):
-        # combinations('ABCD', 2) --> AB AC AD BC BD CD
-        # combinations(range(4), 3) --> 012 013 023 123
-        pool = tuple(iterable)
-        n = len(pool)
-        if r > n:
-            return
-        indices = range(r)
-        yield tuple(pool[i] for i in indices)
-        while True:
-            for i in reversed(range(r)):
-                if indices[i] != i + n - r:
-                    break
-            else:
-                return
-            indices[i] += 1  # pylint: disable=W0631
-            for j in range(i + 1, r):  # pylint: disable=W0631
-                indices[j] = indices[j - 1] + 1
-            yield tuple(pool[i] for i in indices)
-
     @classmethod
     def intersect_combination(cls, combination):
         return reduce(set.intersection, [set(specifiers) for specifiers in combination])
@@ -247,7 +224,7 @@ class TestConfigurationConverter(object):
         def try_collapsing(size, collapsing_sets):
             if len(specifiers_list) < size:
                 return False
-            for combination in self.combinations(specifiers_list, size):
+            for combination in itertools.combinations(specifiers_list, size):
                 if self.symmetric_difference(combination) in collapsing_sets:
                     for item in combination:
                         specifiers_list.remove(item)
@@ -264,7 +241,7 @@ class TestConfigurationConverter(object):
         def try_abbreviating(collapsing_sets):
             if len(specifiers_list) < 2:
                 return False
-            for combination in self.combinations(specifiers_list, 2):
+            for combination in itertools.combinations(specifiers_list, 2):
                 for collapsing_set in collapsing_sets:
                     diff = self.symmetric_difference(combination)
                     if diff <= collapsing_set:
index 8dbabf0..639005b 100644 (file)
@@ -29,6 +29,8 @@
 
 import unittest
 
+from collections import OrderedDict
+
 from webkitpy.common.host_mock import MockHost
 from webkitpy.common.system.outputcapture import OutputCapture
 
@@ -36,12 +38,6 @@ from webkitpy.layout_tests.models.test_configuration import *
 from webkitpy.layout_tests.models.test_expectations import *
 from webkitpy.layout_tests.models.test_configuration import *
 
-try:
-    from collections import OrderedDict
-except ImportError:
-    # Needed for Python < 2.7
-    from webkitpy.thirdparty.ordered_dict import OrderedDict
-
 
 class Base(unittest.TestCase):
     # Note that all of these tests are written assuming the configuration
index 6656341..9074f78 100644 (file)
@@ -41,12 +41,7 @@ import optparse
 import re
 import sys
 
-try:
-    from collections import OrderedDict
-except ImportError:
-    # Needed for Python < 2.7
-    from webkitpy.thirdparty.ordered_dict import OrderedDict
-
+from collections import OrderedDict
 
 from webkitpy.common import find_files
 from webkitpy.common import read_checksum_from_png
index f038f2a..b369e65 100644 (file)
@@ -531,7 +531,7 @@ class ContentBlock(object):
         self.content_hash = None
         self._content_length = None
         # Content is treated as binary data even though the text output is usually UTF-8.
-        self.content = str()  # FIXME: Should be bytearray() once we require Python 2.6.
+        self.content = bytearray()
         self.decoded_content = None
         self.malloc = None
         self.js_heap = None
index 56f9fd8..e1b015c 100644 (file)
@@ -95,8 +95,8 @@ class ServerProcess(object):
                 self._proc.stderr = None
 
         self._proc = None
-        self._output = str()  # bytesarray() once we require Python 2.6
-        self._error = str()  # bytesarray() once we require Python 2.6
+        self._output = bytearray()
+        self._error = bytearray()
         self._crashed = False
         self.timed_out = False