Bug 1559975 - convert testing/web-platform to python3 compatible syntax r=jgraham
☠☠ backed out by 6fe987527965 ☠ ☠
authorEdwin Gao <egao@mozilla.com>
Thu, 29 Aug 2019 23:04:43 +0000
changeset 554529 acf99165d2fd365d6dc54c9a848ddb2caf757820
parent 554528 6e46680a8c11fa13966689916cbe4c8bba87bff1
child 554530 0948113e9229226dc4d126a21fa1b00ba9f75b08
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham
bugs1559975
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1559975 - convert testing/web-platform to python3 compatible syntax r=jgraham Differential Revision: https://phabricator.services.mozilla.com/D37101
testing/web-platform/metasummary.py
testing/web-platform/tests/bluetooth/generate_test.py
testing/web-platform/tests/content-security-policy/embedded-enforcement/support/echo-required-csp.py
testing/web-platform/tests/css/css-fonts/support/fonts/makegsubfonts.py
testing/web-platform/tests/css/tools/w3ctestlib/Sources.py
testing/web-platform/tests/css/tools/w3ctestlib/Utils.py
testing/web-platform/tests/tools/pywebsocket/example/echo_client.py
testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/headerparserhandler.py
testing/web-platform/tests/tools/pywebsocket/test/client_for_testing.py
testing/web-platform/tests/tools/pywebsocket/test/mux_client_for_testing.py
testing/web-platform/tests/tools/pywebsocket/test/test_dispatch.py
testing/web-platform/tests/tools/pywebsocket/test/test_endtoend.py
testing/web-platform/tests/tools/pywebsocket/test/test_handshake_hybi.py
testing/web-platform/tests/tools/pywebsocket/test/test_mux.py
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servodriver.py
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorselenium.py
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py
testing/web-platform/tests/tools/wptserve/tests/functional/docroot/invalid.py
testing/web-platform/update/github.py
testing/web-platform/update/upstream.py
--- a/testing/web-platform/metasummary.py
+++ b/testing/web-platform/metasummary.py
@@ -194,17 +194,17 @@ def run(src_root, obj_root, logger_=None
 
     if kwargs["out_dir"]:
         if not os.path.exists(kwargs["out_dir"]):
             os.makedirs(kwargs["out_dir"])
         out_path = os.path.join(kwargs["out_dir"], "summary.json")
         with open(out_path, "w") as f:
             json.dump(rv, f)
     else:
-        print json.dumps(rv, indent=2)
+        print(json.dumps(rv, indent=2))
 
     if kwargs["meta_dir"]:
         update_wpt_meta(logger_obj, kwargs["meta_dir"], rv)
 
 
 def get_dir_paths(test_root, test_path):
     if not os.path.isabs(test_path):
         test_path = os.path.join(test_root, test_path)
--- a/testing/web-platform/tests/bluetooth/generate_test.py
+++ b/testing/web-platform/tests/bluetooth/generate_test.py
@@ -26,17 +26,17 @@ def main():
   for generated_test in generate.GetGeneratedTests():
     generated_files.add(generated_test.path)
     try:
       with open(generated_test.path, 'r') as f:
         data = f.read().decode('utf-8')
         if data != generated_test.data:
           logging.error('%s does not match template', generated_test.path)
           return -1
-    except IOError, e:
+    except IOError as e:
       if e.errno == 2:
         logging.error('Missing generated test:\n%s\nFor template:\n%s',
                      generated_test.path,
                      generated_test.template)
         return -1
 
   # Tests that there are no obsolete generated files.
   previous_generated_files = set()
--- a/testing/web-platform/tests/content-security-policy/embedded-enforcement/support/echo-required-csp.py
+++ b/testing/web-platform/tests/content-security-policy/embedded-enforcement/support/echo-required-csp.py
@@ -5,17 +5,17 @@ def main(request, response):
     header = request.headers.get("Test-Header-Injection");
     message['test_header_injection'] = header if header else None
 
     header = request.headers.get("Sec-Required-CSP");
     message['required_csp'] = header if header else None
 
     second_level_iframe_code = ""
     if "include_second_level_iframe" in request.GET:
-       if "second_level_iframe_csp" in request.GET and request.GET["second_level_iframe_csp"] <> "":
+       if "second_level_iframe_csp" in request.GET and request.GET["second_level_iframe_csp"] != "":
          second_level_iframe_code = '''<script>
             var i2 = document.createElement('iframe');
             i2.src = 'echo-required-csp.py';
             i2.csp = "{0}";
             document.body.appendChild(i2);
             </script>'''.format(request.GET["second_level_iframe_csp"])
        else:
          second_level_iframe_code = '''<script>
--- a/testing/web-platform/tests/css/css-fonts/support/fonts/makegsubfonts.py
+++ b/testing/web-platform/tests/css/css-fonts/support/fonts/makegsubfonts.py
@@ -120,17 +120,17 @@ def makeLookup1():
             charStrings=charStrings
     	)
     	hmtx[glyphName] = passGlyphMetrics
 
     	for table in cmap.tables:
     		if table.format == 4:
     			table.cmap[cp] = glyphName
     		else:
-    			raise NotImplementedError, "Unsupported cmap table format: %d" % table.format
+                raise NotImplementedError("Unsupported cmap table format: %d" % table.format)
     	cp += 1
 
     	# tag.fail
     	glyphName = "%s.fail" % tag
     	glyphOrder.append(glyphName)
     	addGlyphToCFF(
     		glyphName=glyphName,
     		program=failGlyphProgram,
@@ -141,17 +141,17 @@ def makeLookup1():
             charStrings=charStrings
     	)
     	hmtx[glyphName] = failGlyphMetrics
 
     	for table in cmap.tables:
     		if table.format == 4:
     			table.cmap[cp] = glyphName
     		else:
-    			raise NotImplementedError, "Unsupported cmap table format: %d" % table.format
+                raise NotImplementedError("Unsupported cmap table format: %d" % table.format)
 
         # bump this up so that the sequence is the same as the lookup 3 font
     	cp += 3
 
     # set the glyph order
     shell.setGlyphOrder(glyphOrder)
 
     # start the GSUB
@@ -322,17 +322,17 @@ def makeLookup3():
             charStrings=charStrings
     	)
     	hmtx[glyphName] = passGlyphMetrics
 
     	for table in cmap.tables:
     		if table.format == 4:
     			table.cmap[cp] = glyphName
     		else:
-    			raise NotImplementedError, "Unsupported cmap table format: %d" % table.format
+    			raise NotImplementedError("Unsupported cmap table format: %d" % table.format)
     	cp += 1
 
     	# tag.alt1,2,3
     	for i in range(1,4):
     		glyphName = "%s.alt%d" % (tag, i)
     		glyphOrder.append(glyphName)
     		addGlyphToCFF(
     			glyphName=glyphName,
@@ -343,17 +343,17 @@ def makeLookup3():
     			topDict=topDict,
                 charStrings=charStrings
     		)
     		hmtx[glyphName] = failGlyphMetrics
     		for table in cmap.tables:
     			if table.format == 4:
     				table.cmap[cp] = glyphName
     			else:
-    				raise NotImplementedError, "Unsupported cmap table format: %d" % table.format
+    				raise NotImplementedError("Unsupported cmap table format: %d" % table.format)
     		cp += 1
 
     # set the glyph order
     shell.setGlyphOrder(glyphOrder)
 
     # start the GSUB
     shell["GSUB"] = newTable("GSUB")
     gsub = shell["GSUB"].table = GSUB()
--- a/testing/web-platform/tests/css/tools/w3ctestlib/Sources.py
+++ b/testing/web-platform/tests/css/tools/w3ctestlib/Sources.py
@@ -529,17 +529,17 @@ class FileSource:
         self._data = f.read()
     if (self._data.startswith(codecs.BOM_UTF8)):
       self.encoding = 'utf-8-sig' # XXX look for other unicode BOMs
     return self._data
 
   def unicode(self):
     try:
       return self.data().decode(self.encoding)
-    except UnicodeDecodeError, e:
+    except UnicodeDecodeError:
       return None
 
   def parse(self):
     """Parses and validates FileSource data from sourcepath."""
     self.loadMetadata()
 
   def validate(self):
     """Ensure data is loaded from sourcepath."""
--- a/testing/web-platform/tests/css/tools/w3ctestlib/Utils.py
+++ b/testing/web-platform/tests/css/tools/w3ctestlib/Utils.py
@@ -81,26 +81,26 @@ def relativeURL(start, end):
 def listfiles(path, ext = None):
   """ Returns a list of all files in a directory.
       Optionally lists only files with a given extension.
   """
   try:
     _,_,files = os.walk(path).next()
     if (ext):
       files = [fileName for fileName in files if fileName.endswith(ext)]
-  except StopIteration, e:
+  except StopIteration:
     files = []
   return files
 
 def listdirs(path):
   """ Returns a list of all subdirectories in a directory.
   """
   try:
     _,dirs,_ = os.walk(path).next()
-  except StopIteration, e:
+  except StopIteration:
     dirs = []
   return dirs
 
 ###### MIME types and file extensions ######
 
 extensionMap = { None     : 'application/octet-stream', # default
                  '.xht'   : 'application/xhtml+xml',
                  '.xhtml' : 'application/xhtml+xml',
--- a/testing/web-platform/tests/tools/pywebsocket/example/echo_client.py
+++ b/testing/web-platform/tests/tools/pywebsocket/example/echo_client.py
@@ -522,17 +522,17 @@ class ClientHandshakeProcessor(ClientHan
             False)
 
         accept = _get_mandatory_header(
             fields, common.SEC_WEBSOCKET_ACCEPT_HEADER)
 
         # Validate
         try:
             binary_accept = base64.b64decode(accept)
-        except TypeError, e:
+        except TypeError:
             raise HandshakeError(
                 'Illegal value for header %s: %r' %
                 (common.SEC_WEBSOCKET_ACCEPT_HEADER, accept))
 
         if len(binary_accept) != 20:
             raise ClientHandshakeError(
                 'Decoded value of %s is not 20-byte long' %
                 common.SEC_WEBSOCKET_ACCEPT_HEADER)
@@ -942,17 +942,17 @@ class EchoClient(object):
                 self._stream.send_message(line)
                 if self._options.verbose:
                     print('Send: %s' % line)
                 try:
                     received = self._stream.receive_message()
 
                     if self._options.verbose:
                         print('Recv: %s' % received)
-                except Exception, e:
+                except Exception as e:
                     if self._options.verbose:
                         print('Error: %s' % e)
                     raise
 
             self._do_closing_handshake()
         finally:
             self._socket.close()
 
--- a/testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/headerparserhandler.py
+++ b/testing/web-platform/tests/tools/pywebsocket/mod_pywebsocket/headerparserhandler.py
@@ -196,54 +196,54 @@ def headerparserhandler(request):
         # we don't have request handlers.
         if not _dispatcher.get_handler_suite(request.uri):
             request.log_error(
                 'mod_pywebsocket: No handler for resource: %r' % request.uri,
                 apache.APLOG_INFO)
             request.log_error(
                 'mod_pywebsocket: Fallback to Apache', apache.APLOG_INFO)
             return apache.DECLINED
-    except dispatch.DispatchException, e:
+    except dispatch.DispatchException as e:
         request.log_error(
             'mod_pywebsocket: Dispatch failed for error: %s' % e,
             apache.APLOG_INFO)
         if not handshake_is_done:
             return e.status
 
     try:
         allow_draft75 = _parse_option(
             _PYOPT_ALLOW_DRAFT75,
             apache.main_server.get_options().get(_PYOPT_ALLOW_DRAFT75),
             _PYOPT_ALLOW_DRAFT75_DEFINITION)
 
         try:
             handshake.do_handshake(
                 request, _dispatcher, allowDraft75=allow_draft75)
-        except handshake.VersionException, e:
+        except handshake.VersionException as e:
             request.log_error(
                 'mod_pywebsocket: Handshake failed for version error: %s' % e,
                 apache.APLOG_INFO)
             request.err_headers_out.add(common.SEC_WEBSOCKET_VERSION_HEADER,
                                         e.supported_versions)
             return apache.HTTP_BAD_REQUEST
-        except handshake.HandshakeException, e:
+        except handshake.HandshakeException as e:
             # Handshake for ws/wss failed.
             # Send http response with error status.
             request.log_error(
                 'mod_pywebsocket: Handshake failed for error: %s' % e,
                 apache.APLOG_INFO)
             return e.status
 
         handshake_is_done = True
         request._dispatcher = _dispatcher
         _dispatcher.transfer_data(request)
-    except handshake.AbortedByUserException, e:
+    except handshake.AbortedByUserException as e:
         request.log_error('mod_pywebsocket: Aborted: %s' % e,
                           apache.APLOG_INFO)
-    except Exception, e:
+    except Exception as e:
         # DispatchException can also be thrown if something is wrong in
         # pywebsocket code. It's caught here, then.
 
         request.log_error('mod_pywebsocket: Exception occurred: %s\n%s' %
                           (e, util.get_stack_trace()),
                           apache.APLOG_ERR)
         # Unknown exceptions before handshake mean Apache must handle its
         # request with another handler.
--- a/testing/web-platform/tests/tools/pywebsocket/test/client_for_testing.py
+++ b/testing/web-platform/tests/tools/pywebsocket/test/client_for_testing.py
@@ -393,17 +393,17 @@ class WebSocketHandshake(object):
                 'Multiple Sec-WebSocket-Accept headers found: %s' %
                 fields['sec-websocket-accept'])
 
         accept = fields['sec-websocket-accept'][0]
 
         # Validate
         try:
             decoded_accept = base64.b64decode(accept)
-        except TypeError, e:
+        except TypeError as e:
             raise HandshakeException(
                 'Illegal value for header Sec-WebSocket-Accept: ' + accept)
 
         if len(decoded_accept) != 20:
             raise HandshakeException(
                 'Decoded value of Sec-WebSocket-Accept is not 20-byte long')
 
         self._logger.debug('Actual Sec-WebSocket-Accept: %r (%s)',
@@ -993,17 +993,17 @@ def connect_socket_with_retry(host, port
     while retry_count < retry:
         try:
             s = socket.socket()
             s.settimeout(timeout)
             s.connect((host, port))
             if use_tls:
                 return _TLSSocket(s)
             return s
-        except socket.error, e:
+        except socket.error as e:
             if e.errno != errno.ECONNREFUSED:
                 raise
             else:
                 retry_count = retry_count + 1
                 time.sleep(sleep_sec)
 
     return None
 
@@ -1058,17 +1058,17 @@ class Client(object):
         self._stream.assert_receive_close(code, reason)
 
     def close_socket(self):
         self._socket.close()
 
     def assert_connection_closed(self):
         try:
             read_data = receive_bytes(self._socket, 1)
-        except Exception, e:
+        except Exception as e:
             if str(e).find(
                 'Connection closed before receiving requested length ') == 0:
                 return
             try:
                 error_number, message = e
                 for error_name in ['ECONNRESET', 'WSAECONNRESET']:
                     if (error_name in dir(errno) and
                         error_number == getattr(errno, error_name)):
--- a/testing/web-platform/tests/tools/pywebsocket/test/mux_client_for_testing.py
+++ b/testing/web-platform/tests/tools/pywebsocket/test/mux_client_for_testing.py
@@ -514,17 +514,17 @@ class MuxClient(object):
         if not self._is_active:
             raise Exception('Mux client is not active')
 
         if channel_id in self._logical_channels:
             raise Exception('Channel id %d already exists' % channel_id)
 
         try:
             send_quota = self._channel_slots.popleft()
-        except IndexError, e:
+        except IndexError as e:
             raise Exception('No channel slots: %r' % e)
 
         # Create AddChannel request
         request_line = 'GET %s HTTP/1.1\r\n' % options.resource
         fields = []
         if options.server_port == client_for_testing.DEFAULT_PORT:
             fields.append('Host: %s\r\n' % options.server_host.lower())
         else:
@@ -627,17 +627,17 @@ class MuxClient(object):
         self._stream.send_binary(payload)
 
     def assert_receive(self, channel_id, payload, binary=False):
         self._check_logical_channel_is_opened(channel_id)
 
         try:
             inner_frame = self._logical_channels[channel_id].queue.get(
                 timeout=self._timeout)
-        except Queue.Empty, e:
+        except Queue.Empty as e:
             raise Exception('Cannot receive message from channel id %d' %
                             channel_id)
 
         if binary:
             opcode = client_for_testing.OPCODE_BINARY
         else:
             opcode = client_for_testing.OPCODE_TEXT
 
@@ -661,17 +661,17 @@ class MuxClient(object):
         self._stream.send_binary(payload)
 
     def assert_receive_close(self, channel_id):
         self._check_logical_channel_is_opened(channel_id)
 
         try:
             inner_frame = self._logical_channels[channel_id].queue.get(
                 timeout=self._timeout)
-        except Queue.Empty, e:
+        except Queue.Empty as e:
             raise Exception('Cannot receive message from channel id %d' %
                             channel_id)
         if inner_frame.opcode != client_for_testing.OPCODE_CLOSE:
             raise Exception('Didn\'t receive close frame')
 
     def send_physical_connection_close(self, code=None, reason=''):
         self._physical_connection_close_event = threading.Event()
         self._stream.send_close(code, reason)
--- a/testing/web-platform/tests/tools/pywebsocket/test/test_dispatch.py
+++ b/testing/web-platform/tests/tools/pywebsocket/test/test_dispatch.py
@@ -150,19 +150,19 @@ class DispatcherTest(unittest.TestCase):
         request.ws_resource = '/origin_check'
         request.ws_origin = 'http://example.com'
         dispatcher.do_extra_handshake(request)  # Must not raise exception.
 
         request.ws_origin = 'http://bad.example.com'
         try:
             dispatcher.do_extra_handshake(request)
             self.fail('Could not catch HandshakeException with 403 status')
-        except handshake.HandshakeException, e:
+        except handshake.HandshakeException as e:
             self.assertEquals(403, e.status)
-        except Exception, e:
+        except Exception as e:
             self.fail('Unexpected exception: %r' % e)
 
     def test_abort_extra_handshake(self):
         dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None)
         request = mock.MockRequest()
         request.ws_resource = '/abort_by_user'
         self.assertRaises(handshake.AbortedByUserException,
                           dispatcher.do_extra_handshake, request)
@@ -207,30 +207,30 @@ class DispatcherTest(unittest.TestCase):
         for resource in ['/blank', '/sub/non_callable',
                          '/sub/no_wsh_at_the_end', '/does/not/exist']:
             request = mock.MockRequest(connection=mock.MockConn(''))
             request.ws_resource = resource
             request.ws_protocol = 'p2'
             try:
                 dispatcher.transfer_data(request)
                 self.fail()
-            except dispatch.DispatchException, e:
+            except dispatch.DispatchException as e:
                 self.failUnless(str(e).find('No handler') != -1)
             except Exception:
                 self.fail()
 
     def test_transfer_data_handler_exception(self):
         dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None)
         request = mock.MockRequest(connection=mock.MockConn(''))
         request.ws_resource = '/sub/exception_in_transfer'
         request.ws_protocol = 'p3'
         try:
             dispatcher.transfer_data(request)
             self.fail()
-        except Exception, e:
+        except Exception as e:
             self.failUnless(str(e).find('Intentional') != -1,
                             'Unexpected exception: %s' % e)
 
     def test_abort_transfer_data(self):
         dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None)
         request = mock.MockRequest()
         request.ws_resource = '/abort_by_user'
         self.assertRaises(handshake.AbortedByUserException,
--- a/testing/web-platform/tests/tools/pywebsocket/test/test_endtoend.py
+++ b/testing/web-platform/tests/tools/pywebsocket/test/test_endtoend.py
@@ -299,19 +299,19 @@ class EndToEndHyBiTest(EndToEndTestBase)
         server = self._run_server()
         try:
             time.sleep(_SERVER_WARMUP_IN_SEC)
 
             client = client_for_testing.create_client(options)
             try:
                 client.connect()
                 self.fail('Could not catch HttpStatusException')
-            except client_for_testing.HttpStatusException, e:
+            except client_for_testing.HttpStatusException as e:
                 self.assertEqual(status, e.status)
-            except Exception, e:
+            except Exception as e:
                 self.fail('Catch unexpected exception')
             finally:
                 client.close_socket()
         finally:
             self._kill_process(server.pid)
 
     def _run_mux_test(self, test_function):
         server = self._run_server()
--- a/testing/web-platform/tests/tools/pywebsocket/test/test_handshake_hybi.py
+++ b/testing/web-platform/tests/tools/pywebsocket/test/test_handshake_hybi.py
@@ -502,20 +502,20 @@ class HandshakerTest(unittest.TestCase):
 
         for (case_name, request_def, expected_status,
              expect_handshake_exception) in bad_cases:
             request = _create_request(request_def)
             handshaker = Handshaker(request, mock.MockDispatcher())
             try:
                 handshaker.do_handshake()
                 self.fail('No exception thrown for \'%s\' case' % case_name)
-            except HandshakeException, e:
+            except HandshakeException as e:
                 self.assertTrue(expect_handshake_exception)
                 self.assertEqual(expected_status, e.status)
-            except VersionException, e:
+            except VersionException as e:
                 self.assertFalse(expect_handshake_exception)
 
 
 if __name__ == '__main__':
     unittest.main()
 
 
 # vi:sts=4 sw=4 et
--- a/testing/web-platform/tests/tools/pywebsocket/test/test_mux.py
+++ b/testing/web-platform/tests/tools/pywebsocket/test/test_mux.py
@@ -253,19 +253,19 @@ class _MuxMockDispatcher(object):
                     request, self.channel_events[request.channel_id])
             elif request.uri.endswith('ping_while_hello_world'):
                 self._do_ping_while_hello_world(
                     request, self.channel_events[request.channel_id])
             else:
                 raise ValueError('Cannot handle path %r' % request.path)
             if not request.server_terminated:
                 request.ws_stream.close_connection()
-        except ConnectionTerminatedException, e:
+        except ConnectionTerminatedException as e:
             self.channel_events[request.channel_id].exception = e
-        except Exception, e:
+        except Exception as e:
             self.channel_events[request.channel_id].exception = e
             raise
 
 
 def _create_mock_request(connection=None, logical_channel_extensions=None):
     if connection is None:
         connection = _MockMuxConnection()
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servodriver.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servodriver.py
@@ -58,17 +58,17 @@ def env_extras(**kwargs):
 
 def env_options():
     return {"server_host": "127.0.0.1",
             "testharnessreport": "testharnessreport-servodriver.js",
             "supports_debugger": True}
 
 
 def update_properties():
-    return ["debug", "os", "processor"], {"os": ["version"], "processor": ["bits"]}
+    return (["debug", "os", "processor"], {"os": ["version"], "processor": ["bits"]})
 
 
 def write_hosts_file(config):
     hosts_fd, hosts_path = tempfile.mkstemp()
     with os.fdopen(hosts_fd, "w") as f:
         f.write(make_hosts_file(config, "127.0.0.1"))
     return hosts_path
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py
@@ -493,17 +493,17 @@ class WdspecRun(object):
                 message += "\n"
             message += traceback.format_exc(e)
             self.result = False, ("INTERNAL-ERROR", message)
         finally:
             self.result_flag.set()
 
 
 class ConnectionlessBaseProtocolPart(BaseProtocolPart):
-    def execute_script(self, script, async=False):
+    def execute_script(self, script, asynchronous=False):
         pass
 
     def set_timeout(self, timeout):
         pass
 
     def wait(self):
         pass
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
@@ -51,18 +51,18 @@ def do_delayed_imports():
 class MarionetteBaseProtocolPart(BaseProtocolPart):
     def __init__(self, parent):
         super(MarionetteBaseProtocolPart, self).__init__(parent)
         self.timeout = None
 
     def setup(self):
         self.marionette = self.parent.marionette
 
-    def execute_script(self, script, async=False):
-        method = self.marionette.execute_async_script if async else self.marionette.execute_script
+    def execute_script(self, script, asynchronous=False):
+        method = self.marionette.execute_async_script if asynchronous else self.marionette.execute_script
         return method(script, new_sandbox=False, sandbox=None)
 
     def set_timeout(self, timeout):
         """Set the Marionette script timeout.
 
         :param timeout: Script timeout in seconds
 
         """
@@ -733,17 +733,17 @@ class MarionetteTestharnessExecutor(Test
         protocol.base.execute_script("window.open(undefined, '%s', 'noopener')" % self.window_id)
         test_window = protocol.testharness.get_test_window(self.window_id, parent_window,
                                                            timeout=10*self.timeout_multiplier)
         self.protocol.base.set_window(test_window)
         handler = CallbackHandler(self.logger, protocol, test_window)
         protocol.marionette.navigate(url)
         while True:
             result = protocol.base.execute_script(
-                self.script_resume % format_map, async=True)
+                self.script_resume % format_map, asynchronous=True)
             if result is None:
                 # This can happen if we get an content process crash
                 return None
             done, rv = handler(result)
             if done:
                 break
 
         if self.protocol.coverage.is_enabled:
@@ -853,17 +853,17 @@ class MarionetteRefTestExecutor(RefTestE
                                      self._screenshot,
                                      self.protocol,
                                      test_url,
                                      timeout).run()
 
     def _screenshot(self, protocol, url, timeout):
         protocol.marionette.navigate(url)
 
-        protocol.base.execute_script(self.wait_script, async=True)
+        protocol.base.execute_script(self.wait_script, asynchronous=True)
 
         screenshot = protocol.marionette.screenshot(full=False)
         # strip off the data:img/png, part of the url
         if screenshot.startswith("data:image/png;base64,"):
             screenshot = screenshot.split(",", 1)[1]
 
         return screenshot
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorselenium.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorselenium.py
@@ -41,18 +41,18 @@ def do_delayed_imports():
     from selenium.webdriver.remote.remote_connection import RemoteConnection
     from selenium.webdriver.remote.command import Command
 
 
 class SeleniumBaseProtocolPart(BaseProtocolPart):
     def setup(self):
         self.webdriver = self.parent.webdriver
 
-    def execute_script(self, script, async=False):
-        method = self.webdriver.execute_async_script if async else self.webdriver.execute_script
+    def execute_script(self, script, asynchronous=False):
+        method = self.webdriver.execute_async_script if asynchronous else self.webdriver.execute_script
         return method(script)
 
     def set_timeout(self, timeout):
         self.webdriver.set_script_timeout(timeout * 1000)
 
     @property
     def current_window(self):
         return self.webdriver.current_window_handle
@@ -330,17 +330,17 @@ class SeleniumTestharnessExecutor(Testha
         protocol.base.execute_script("window.open('about:blank', '%s', 'noopener')" % self.window_id)
         test_window = protocol.testharness.get_test_window(self.window_id, parent_window,
                                                            timeout=5*self.timeout_multiplier)
         self.protocol.base.set_window(test_window)
         protocol.webdriver.get(url)
         handler = CallbackHandler(self.logger, protocol, test_window)
         while True:
             result = protocol.base.execute_script(
-                self.script_resume % format_map, async=True)
+                self.script_resume % format_map, asynchronous=True)
             done, rv = handler(result)
             if done:
                 break
         return rv
 
 
 class SeleniumRefTestExecutor(RefTestExecutor):
     def __init__(self, browser, server_config, timeout_multiplier=1,
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py
@@ -62,17 +62,17 @@ def parse_pref_value(value):
         return False
     try:
         return float(value)
     except ValueError:
         return value
 
 
 class ServoBaseProtocolPart(BaseProtocolPart):
-    def execute_script(self, script, async=False):
+    def execute_script(self, script, asynchronous=False):
         pass
 
     def set_timeout(self, timeout):
         pass
 
     def wait(self):
         pass
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
@@ -29,18 +29,18 @@ import webdriver as client
 
 here = os.path.join(os.path.split(__file__)[0])
 
 
 class WebDriverBaseProtocolPart(BaseProtocolPart):
     def setup(self):
         self.webdriver = self.parent.webdriver
 
-    def execute_script(self, script, async=False):
-        method = self.webdriver.execute_async_script if async else self.webdriver.execute_script
+    def execute_script(self, script, asynchronous=False):
+        method = self.webdriver.execute_async_script if asynchronous else self.webdriver.execute_script
         return method(script)
 
     def set_timeout(self, timeout):
         try:
             self.webdriver.timeouts.script = timeout
         except client.WebDriverException:
             # workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2057
             body = {"type": "script", "ms": timeout * 1000}
@@ -362,17 +362,17 @@ class WebDriverTestharnessExecutor(Testh
         handler = CallbackHandler(self.logger, protocol, test_window)
         protocol.webdriver.url = url
 
         if not self.supports_eager_pageload:
             self.wait_for_load(protocol)
 
         while True:
             result = protocol.base.execute_script(
-                self.script_resume % format_map, async=True)
+                self.script_resume % format_map, asynchronous=True)
 
             # As of 2019-03-29, WebDriver does not define expected behavior for
             # cases where the browser crashes during script execution:
             #
             # https://github.com/w3c/webdriver/issues/1308
             if not isinstance(result, list) or len(result) != 2:
                 try:
                     is_alive = self.is_alive()
@@ -396,17 +396,17 @@ class WebDriverTestharnessExecutor(Testh
                 loaded = protocol.base.execute_script("""
 var callback = arguments[arguments.length - 1];
 if (location.href === "about:blank") {
   callback(false);
 } else if (document.readyState !== "loading") {
   callback(true);
 } else {
   document.addEventListener("readystatechange", () => {if (document.readyState !== "loading") {callback(true)}});
-}""", async=True)
+}""", asynchronous=True)
             except client.JavascriptErrorException:
                 # We can get an error here if the script runs in the initial about:blank
                 # document before it has navigated, with the driver returning an error
                 # indicating that the document was unloaded
                 if seen_error:
                     raise
                 seen_error = True
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py
@@ -104,21 +104,21 @@ class ProtocolPart(object):
 
 class BaseProtocolPart(ProtocolPart):
     """Generic bits of protocol that are required for multiple test types"""
     __metaclass__ = ABCMeta
 
     name = "base"
 
     @abstractmethod
-    def execute_script(self, script, async=False):
+    def execute_script(self, script, asynchronous=False):
         """Execute javascript in the current Window.
 
         :param str script: The js source to execute. This is implicitly wrapped in a function.
-        :param bool async: Whether the script is asynchronous in the webdriver
+        :param bool asynchronous: Whether the script is asynchronous in the webdriver
                            sense i.e. whether the return value is the result of
                            the initial function call or if it waits for some callback.
         :returns: The result of the script execution.
         """
         pass
 
     @abstractmethod
     def set_timeout(self, timeout):
--- a/testing/web-platform/tests/tools/wptserve/tests/functional/docroot/invalid.py
+++ b/testing/web-platform/tests/tools/wptserve/tests/functional/docroot/invalid.py
@@ -1,3 +1,3 @@
 # Oops...
-def main(request, response
+def main(request, response):
     return "FAIL"
--- a/testing/web-platform/update/github.py
+++ b/testing/web-platform/update/github.py
@@ -44,17 +44,17 @@ class GitHub(object):
         if data is not None:
             kwargs["data"] = json.dumps(data)
 
         resp = requests.request(method, url, **kwargs)
 
         if 200 <= resp.status_code < 300:
             return resp.json()
         else:
-            print method, path, resp.status_code, resp.json()
+            print(method, path, resp.status_code, resp.json())
             raise GitHubError(resp.status_code, resp.json())
 
     def repo(self, owner, name):
         """GitHubRepo for a particular repository.
 
         :param owner: String repository owner
         :param name: String repository name
         """
--- a/testing/web-platform/update/upstream.py
+++ b/testing/web-platform/update/upstream.py
@@ -166,34 +166,34 @@ class LoadCommits(Step):
 
 class SelectCommits(Step):
     """Provide a UI to select which commits to upstream"""
 
     def create(self, state):
         while True:
             commits = state.source_commits[:]
             for i, commit in enumerate(commits):
-                print "%i:\t%s" % (i, commit.message.summary)
+                print("{}:\t{}".format(i, commit.message.summary))
 
             remove = raw_input("Provide a space-separated list of any commits numbers to remove from the list to upstream:\n").strip()
             remove_idx = set()
             for item in remove.split(" "):
                 try:
                     item = int(item)
                 except:
                     continue
                 if item < 0 or item >= len(commits):
                     continue
                 remove_idx.add(item)
 
             keep_commits = [(i,cmt) for i,cmt in enumerate(commits) if i not in remove_idx]
             #TODO: consider printed removed commits
-            print "Selected the following commits to keep:"
+            print("Selected the following commits to keep:")
             for i, commit in keep_commits:
-                print "%i:\t%s" % (i, commit.message.summary)
+                print("{}:\t{}".format(i, commit.message.summary))
             confirm = raw_input("Keep the above commits? y/n\n").strip().lower()
 
             if confirm == "y":
                 state.source_commits = [item[1] for item in keep_commits]
                 break
 
 class MovePatches(Step):
     """Convert gecko commits into patches against upstream and commit these to the sync tree."""
@@ -230,20 +230,20 @@ class MovePatches(Step):
                 self.logger.info("Skipping empty patch")
                 state.commits_loaded = i
                 continue
             try:
                 state.sync_tree.import_patch(stripped_patch)
             except:
                 with tempfile.NamedTemporaryFile(delete=False, suffix=".diff") as f:
                     f.write(stripped_patch.diff)
-                    print """Patch failed to apply. Diff saved in %s
-Fix this file so it applies and run with --continue""" % f.name
+                    print("""Patch failed to apply. Diff saved in {}
+Fix this file so it applies and run with --continue""".format(f.name))
                     state.patch = (f.name, stripped_patch)
-                    print state.patch
+                    print(state.patch)
                 sys.exit(1)
             state.commits_loaded = i
         raw_input("Check for differences with upstream")
 
 
 class RebaseCommits(Step):
     """Rebase commits from the current branch on top of the upstream destination branch.