[Windows] Fix error while launching subprocess on Windows Python
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Nov 2017 03:46:12 +0000 (03:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Nov 2017 03:46:12 +0000 (03:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179637

Patch by Basuke Suzuki <Basuke.Suzuki@sony.com> on 2017-11-14
Reviewed by Alex Christensen.

To pass environment variables to subprocess.popen on Windows Python 2,
the dict values must be str not unicode.
Also is_native_win() method is added to port.

* Scripts/webkitpy/common/system/platforminfo.py:
(PlatformInfo.is_native_win):
* Scripts/webkitpy/common/system/platforminfo_mock.py:
(MockPlatformInfo.is_native_win):
* Scripts/webkitpy/common/system/platforminfo_unittest.py:
(TestPlatformInfo.test_os_name_and_wrappers):
* Scripts/webkitpy/port/server_process.py:
(ServerProcess.__init__):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/platforminfo.py
Tools/Scripts/webkitpy/common/system/platforminfo_mock.py
Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py
Tools/Scripts/webkitpy/port/server_process.py

index b12b3d5..43d0d59 100644 (file)
@@ -1,3 +1,23 @@
+2017-11-14  Basuke Suzuki  <Basuke.Suzuki@sony.com>
+
+        [Windows] Fix error while launching subprocess on Windows Python
+        https://bugs.webkit.org/show_bug.cgi?id=179637
+
+        Reviewed by Alex Christensen.
+
+        To pass environment variables to subprocess.popen on Windows Python 2,
+        the dict values must be str not unicode.
+        Also is_native_win() method is added to port.
+
+        * Scripts/webkitpy/common/system/platforminfo.py:
+        (PlatformInfo.is_native_win):
+        * Scripts/webkitpy/common/system/platforminfo_mock.py:
+        (MockPlatformInfo.is_native_win):
+        * Scripts/webkitpy/common/system/platforminfo_unittest.py:
+        (TestPlatformInfo.test_os_name_and_wrappers):
+        * Scripts/webkitpy/port/server_process.py:
+        (ServerProcess.__init__):
+
 2017-11-14  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Move JSONValues to WTF and convert uses of InspectorValues.h to JSONValues.h
index f262a66..0dae4e9 100644 (file)
@@ -70,6 +70,9 @@ class PlatformInfo(object):
     def is_win(self):
         return self.os_name == 'win'
 
+    def is_native_win(self):
+        return self.is_win() and not self.is_cygwin()
+
     def is_cygwin(self):
         return self._is_cygwin
 
index 55bc04d..7b88c0a 100644 (file)
@@ -48,6 +48,9 @@ class MockPlatformInfo(object):
     def is_win(self):
         return self.os_name == 'win'
 
+    def is_native_win(self):
+        return self.is_win() and not self.is_cygwin()
+
     def is_cygwin(self):
         return self.os_name == 'cygwin'
 
index adca387..e5bd5dc 100644 (file)
@@ -111,6 +111,7 @@ class TestPlatformInfo(unittest.TestCase):
         self.assertFalse(info.is_linux())
         self.assertFalse(info.is_mac())
         self.assertTrue(info.is_win())
+        self.assertTrue(info.is_native_win())
         self.assertFalse(info.is_freebsd())
 
         info = self.make_info(fake_sys('cygwin'), executive=fake_executive('6.1.7600'))
@@ -118,6 +119,7 @@ class TestPlatformInfo(unittest.TestCase):
         self.assertFalse(info.is_linux())
         self.assertFalse(info.is_mac())
         self.assertTrue(info.is_win())
+        self.assertFalse(info.is_native_win())
         self.assertFalse(info.is_freebsd())
 
         info = self.make_info(fake_sys('freebsd8'))
index 2d783e7..e690ac4 100644 (file)
@@ -64,7 +64,13 @@ class ServerProcess(object):
         self._port = port_obj
         self._name = name  # Should be the command name (e.g. DumpRenderTree, ImageDiff)
         self._cmd = cmd
-        self._env = env
+
+        # Windows does not allow unicode values in the environment
+        if env and self._port.host.platform.is_native_win():
+            self._env = {key: env[key].encode('utf-8') for key in env}
+        else:
+            self._env = env
+
         # Set if the process outputs non-standard newlines like '\r\n' or '\r'.
         # Don't set if there will be binary data or the data must be ASCII encoded.
         self._universal_newlines = universal_newlines