Bug 1681096 - python3 - pylint --py3k - W1648: Module moved in Python 3 (bad-python3-import) r=aki,gbrown
authorBob Clary <bclary@bclary.com>
Tue, 08 Dec 2020 23:20:08 +0000
changeset 560769 c1f32d5e34e27184fbd22eaccd92a897eff380db
parent 560768 d078689107951597bb1fe0864ae3fb2b10ac5871
child 560770 4d8c196e221470b630d5981e6e790fb45991a63b
push id38033
push userdluca@mozilla.com
push dateTue, 15 Dec 2020 21:34:27 +0000
treeherdermozilla-central@914398229db8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaki, gbrown
bugs1681096
milestone86.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 1681096 - python3 - pylint --py3k - W1648: Module moved in Python 3 (bad-python3-import) r=aki,gbrown Differential Revision: https://phabricator.services.mozilla.com/D99093
testing/mochitest/tests/python/conftest.py
testing/mochitest/tests/python/test_message_logger.py
testing/mozharness/mozharness/mozilla/repo_manipulation.py
testing/tps/create_venv.py
--- a/testing/mochitest/tests/python/conftest.py
+++ b/testing/mochitest/tests/python/conftest.py
@@ -1,17 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
+import six
 import json
 import os
 from argparse import Namespace
-from cStringIO import StringIO
 
 import pytest
 
 import mozinfo
 from manifestparser import TestManifest, expression
 from moztest.selftest.fixtures import binary, setup_test_harness  # noqa
 
 here = os.path.abspath(os.path.dirname(__file__))
@@ -35,17 +35,18 @@ def runtests(setup_test_harness, binary,
               used to override the default mochitest options, they are optional.
     """
     setup_test_harness(*setup_args)
     runtests = pytest.importorskip("runtests")
 
     mochitest_root = runtests.SCRIPT_DIR
     test_root = os.path.join(mochitest_root, "tests", "selftests")
 
-    buf = StringIO()
+    # pylint --py3k: W1648
+    buf = six.StringIO()
     options = vars(parser.parse_args([]))
     options.update(
         {
             "app": binary,
             "keep_open": False,
             "log_raw": [buf],
         }
     )
--- a/testing/mochitest/tests/python/test_message_logger.py
+++ b/testing/mochitest/tests/python/test_message_logger.py
@@ -1,32 +1,32 @@
 # Any copyright is dedicated to the Public Domain.
 # http://creativecommons.org/publicdomain/zero/1.0/
 
 from __future__ import absolute_import, print_function
 
+import six
 import json
 import time
 import types
-from StringIO import StringIO
 
 import mozunit
 import pytest
 from conftest import setup_args
 from mozlog.formatters import JSONFormatter
 from mozlog.handlers.base import StreamHandler
 from mozlog.structuredlog import StructuredLogger
 from six import string_types
 
 
 @pytest.fixture
 def logger():
     logger = StructuredLogger("mochitest_message_logger")
 
-    buf = StringIO()
+    buf = six.StringIO()
     handler = StreamHandler(buf, JSONFormatter())
     logger.add_handler(handler)
     return logger
 
 
 @pytest.fixture
 def get_message_logger(setup_test_harness, logger):
     setup_test_harness(*setup_args)
--- a/testing/mozharness/mozharness/mozilla/repo_manipulation.py
+++ b/testing/mozharness/mozharness/mozilla/repo_manipulation.py
@@ -1,15 +1,21 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import
 import six
-import ConfigParser
+
+# pylint --py3k: W1648
+if six.PY2:
+    from ConfigParser import ConfigParser
+else:
+    from configparser import ConfigParser
+
 import json
 import os
 
 from mozharness.base.errors import HgErrorList
 from mozharness.base.log import FATAL, INFO
 from mozharness.base.vcs.mercurial import MercurialVCS
 
 
@@ -204,14 +210,14 @@ the script (--clean-repos --pull --migra
     def edit_repo_hg_rc(self, cwd, section, key, value):
         hg_rc = self.read_repo_hg_rc(cwd)
         hg_rc.set(section, key, value)
 
         with open(self._get_hg_rc_path(cwd), "wb") as f:
             hg_rc.write(f)
 
     def read_repo_hg_rc(self, cwd):
-        hg_rc = ConfigParser.ConfigParser()
+        hg_rc = ConfigParser()
         hg_rc.read(self._get_hg_rc_path(cwd))
         return hg_rc
 
     def _get_hg_rc_path(self, cwd):
         return os.path.join(cwd, ".hg", "hgrc")
--- a/testing/tps/create_venv.py
+++ b/testing/tps/create_venv.py
@@ -12,17 +12,16 @@ all the virtualenv files will show up in
 from __future__ import absolute_import, print_function
 
 import six
 import optparse
 import os
 import shutil
 import subprocess
 import sys
-import urllib2
 import zipfile
 
 
 here = os.path.dirname(os.path.abspath(__file__))
 usage_message = """
 ***********************************************************************
 
 To run TPS, activate the virtualenv using:
@@ -51,17 +50,17 @@ if sys.platform == "win32":
 else:
     bin_name = os.path.join("bin", "activate")
     activate_env = os.path.join("bin", "activate_this.py")
     python_env = os.path.join("bin", "python")
 
 
 def download(url, target):
     """Downloads the specified url to the given target."""
-    response = urllib2.urlopen(url)
+    response = six.moves.urllib.request.urlopen(url)
     with open(target, "wb") as f:
         f.write(response.read())
 
     return target
 
 
 def setup_virtualenv(target, python_bin=None):
     script_path = os.path.join(