← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:unsixify into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:unsixify into launchpad-buildd:master.

Commit message:
Remove use of six

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/429742
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:unsixify into launchpad-buildd:master.
diff --git a/bin/test_buildd_generatetranslationtemplates b/bin/test_buildd_generatetranslationtemplates
index e981ef0..9cce305 100755
--- a/bin/test_buildd_generatetranslationtemplates
+++ b/bin/test_buildd_generatetranslationtemplates
@@ -6,8 +6,7 @@
 # TranslationTemplatesBuildManager through XMLRPC.
 
 import sys
-
-from six.moves.xmlrpc_client import ServerProxy
+from xmlrpc.client import ServerProxy
 
 if len(sys.argv) != 2:
     print("Usage: %s <chroot_sha1>" % sys.argv[0])
diff --git a/bin/test_buildd_recipe b/bin/test_buildd_recipe
index 89803e6..9090688 100755
--- a/bin/test_buildd_recipe
+++ b/bin/test_buildd_recipe
@@ -6,8 +6,7 @@
 # recipe, without involving the BuilderBehaviour.
 
 import sys
-
-from six.moves.xmlrpc_client import ServerProxy
+from xmlrpc.client import ServerProxy
 
 country_code = 'us'
 apt_cacher_ng_host = 'stumpy'
diff --git a/debian/changelog b/debian/changelog
index b10ccb5..aa2253a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+launchpad-buildd (222) UNRELEASED; urgency=medium
+
+  * Remove use of six.
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx>  Mon, 12 Sep 2022 09:50:13 +0100
+
 launchpad-buildd (221) focal; urgency=medium
 
   [ Andy Whitcroft ]
diff --git a/debian/control b/debian/control
index a9e3850..b881694 100644
--- a/debian/control
+++ b/debian/control
@@ -23,7 +23,6 @@ Build-Depends: apt-utils,
                python3-requests,
                python3-responses,
                python3-setuptools,
-               python3-six,
                python3-systemfixtures,
                python3-testtools,
                python3-twisted (>= 16.4.0),
diff --git a/lpbuildd/builder.py b/lpbuildd/builder.py
index 336594c..2f256ad 100644
--- a/lpbuildd/builder.py
+++ b/lpbuildd/builder.py
@@ -14,15 +14,15 @@ import re
 import shutil
 import sys
 import tempfile
-
-import apt
-from six.moves.urllib.request import (
+from urllib.request import (
     build_opener,
     HTTPBasicAuthHandler,
     HTTPPasswordMgrWithDefaultRealm,
     urlopen,
     )
-from six.moves.xmlrpc_client import Binary
+from xmlrpc.client import Binary
+
+import apt
 from twisted.internet import protocol
 from twisted.internet import reactor as default_reactor
 from twisted.internet import process
diff --git a/lpbuildd/ci.py b/lpbuildd/ci.py
index 3401aae..c49a24c 100644
--- a/lpbuildd/ci.py
+++ b/lpbuildd/ci.py
@@ -1,14 +1,14 @@
 # Copyright 2022 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from configparser import (
+    NoOptionError,
+    NoSectionError,
+    )
 import os
 import tempfile
 import yaml
 
-from six.moves.configparser import (
-    NoOptionError,
-    NoSectionError,
-    )
 from twisted.internet import defer
 
 from lpbuildd.debian import (
diff --git a/lpbuildd/debian.py b/lpbuildd/debian.py
index 5cb47e7..f66bf27 100644
--- a/lpbuildd/debian.py
+++ b/lpbuildd/debian.py
@@ -5,14 +5,14 @@
 #      and Adam Conrad <adam.conrad@xxxxxxxxxxxxx>
 
 import base64
+from configparser import (
+    NoOptionError,
+    NoSectionError,
+    )
 import os
 import re
 import signal
 
-from six.moves.configparser import (
-    NoOptionError,
-    NoSectionError,
-    )
 from twisted.internet import (
     defer,
     threads,
diff --git a/lpbuildd/livefs.py b/lpbuildd/livefs.py
index f627e76..3cc2fb3 100644
--- a/lpbuildd/livefs.py
+++ b/lpbuildd/livefs.py
@@ -1,12 +1,11 @@
 # Copyright 2013-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-import os
-
-from six.moves.configparser import (
+from configparser import (
     NoOptionError,
     NoSectionError,
     )
+import os
 
 from lpbuildd.debian import (
     DebianBuildManager,
diff --git a/lpbuildd/oci.py b/lpbuildd/oci.py
index fdce1aa..e112caf 100644
--- a/lpbuildd/oci.py
+++ b/lpbuildd/oci.py
@@ -1,6 +1,10 @@
 # Copyright 2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from configparser import (
+    NoOptionError,
+    NoSectionError,
+    )
 import gzip
 import hashlib
 import json
@@ -9,11 +13,6 @@ import shutil
 import tarfile
 import tempfile
 
-from six.moves.configparser import (
-    NoOptionError,
-    NoSectionError,
-    )
-
 from lpbuildd.debian import (
     DebianBuildManager,
     DebianBuildState,
diff --git a/lpbuildd/pottery/tests/test_intltool.py b/lpbuildd/pottery/tests/test_intltool.py
index b540c1d..28ff021 100644
--- a/lpbuildd/pottery/tests/test_intltool.py
+++ b/lpbuildd/pottery/tests/test_intltool.py
@@ -2,12 +2,12 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 import errno
+from io import StringIO
 import os
 import tarfile
 from textwrap import dedent
 
 from fixtures import TempDir
-from six import StringIO
 from testtools import TestCase
 from testtools.matchers import (
     Equals,
diff --git a/lpbuildd/proxy.py b/lpbuildd/proxy.py
index 9c56780..94a383f 100644
--- a/lpbuildd/proxy.py
+++ b/lpbuildd/proxy.py
@@ -3,16 +3,16 @@
 
 import base64
 import io
-
-from six.moves.urllib.error import (
+from urllib.error import (
     HTTPError,
     URLError,
     )
-from six.moves.urllib.parse import urlparse
-from six.moves.urllib.request import (
+from urllib.parse import urlparse
+from urllib.request import (
     Request,
     urlopen,
     )
+
 from twisted.application import strports
 from twisted.internet import reactor
 from twisted.internet.interfaces import IHalfCloseableProtocol
diff --git a/lpbuildd/snap.py b/lpbuildd/snap.py
index cd90106..07d9f3e 100644
--- a/lpbuildd/snap.py
+++ b/lpbuildd/snap.py
@@ -1,12 +1,11 @@
 # Copyright 2015-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-import os
-
-from six.moves.configparser import (
+from configparser import (
     NoOptionError,
     NoSectionError,
     )
+import os
 
 from lpbuildd.debian import (
     DebianBuildManager,
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index 9a8efec..30c5ecc 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -7,8 +7,7 @@ import logging
 import os.path
 import tempfile
 from textwrap import dedent
-
-from six.moves.urllib.parse import urlparse
+from urllib.parse import urlparse
 
 from lpbuildd.target.operation import Operation
 from lpbuildd.target.proxy import BuilderProxyOperationMixin
diff --git a/lpbuildd/target/chroot.py b/lpbuildd/target/chroot.py
index 27c6e01..11752c8 100644
--- a/lpbuildd/target/chroot.py
+++ b/lpbuildd/target/chroot.py
@@ -7,8 +7,6 @@ import stat
 import subprocess
 import time
 
-import six
-
 from lpbuildd.target.backend import (
     Backend,
     BackendException,
@@ -73,10 +71,6 @@ class Chroot(Backend):
         if echo:
             print("Running in chroot: %s" % ' '.join(
                 shell_escape(arg) for arg in args))
-        if six.PY2:
-            # The behaviour of non-bytes subprocess arguments in Python 2
-            # depends on the interpreter's startup locale.
-            args = [arg.encode("UTF-8") for arg in args]
         cmd = ["sudo", "/usr/sbin/chroot", self.chroot_path] + args
         if input_text is None and not get_output:
             subprocess.check_call(cmd, **kwargs)
diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py
index fbb6f14..d58d9ab 100644
--- a/lpbuildd/target/lxd.py
+++ b/lpbuildd/target/lxd.py
@@ -16,7 +16,6 @@ import time
 import netaddr
 import pylxd
 from pylxd.exceptions import LXDAPIException
-import six
 
 from lpbuildd.target.backend import (
     Backend,
@@ -532,10 +531,6 @@ class LXD(Backend):
         if echo:
             print("Running in container: %s" % ' '.join(
                 shell_escape(arg) for arg in args))
-        if six.PY2:
-            # The behaviour of non-bytes subprocess arguments in Python 2
-            # depends on the interpreter's startup locale.
-            args = [arg.encode("UTF-8") for arg in args]
         # pylxd's Container.execute doesn't support sending stdin, and it's
         # tedious to implement ourselves.
         cmd = ["lxc", "exec", self.name] + env_params + ["--"] + args
diff --git a/lpbuildd/target/snapstore.py b/lpbuildd/target/snapstore.py
index a46bb5a..e087d7e 100644
--- a/lpbuildd/target/snapstore.py
+++ b/lpbuildd/target/snapstore.py
@@ -1,13 +1,14 @@
 # Copyright 2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-import requests
-from six.moves.urllib.parse import (
+from urllib.parse import (
     urljoin,
     urlparse,
     urlunparse,
     )
 
+import requests
+
 
 class SnapStoreOperationMixin:
     """Methods supporting operations that interact with the snap store."""
diff --git a/lpbuildd/target/tests/test_chroot.py b/lpbuildd/target/tests/test_chroot.py
index e77c455..a8971d3 100644
--- a/lpbuildd/target/tests/test_chroot.py
+++ b/lpbuildd/target/tests/test_chroot.py
@@ -11,7 +11,6 @@ from fixtures import (
     EnvironmentVariable,
     TempDir,
     )
-import six
 from systemfixtures import (
     FakeProcesses,
     FakeTime,
@@ -131,7 +130,7 @@ class TestChroot(TestCase):
         expected_args = [
             ["sudo", "/usr/sbin/chroot",
              "/expected/home/build-1/chroot-autobuild",
-             "linux64", "echo", arg.encode("UTF-8") if six.PY2 else arg],
+             "linux64", "echo", arg],
             ]
         self.assertEqual(
             expected_args,
diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py
index 8258d0f..ecf3ddd 100644
--- a/lpbuildd/target/tests/test_lxd.py
+++ b/lpbuildd/target/tests/test_lxd.py
@@ -20,7 +20,6 @@ from fixtures import (
     )
 import pylxd
 from pylxd.exceptions import LXDAPIException
-import six
 from systemfixtures import (
     FakeFilesystem as _FakeFilesystem,
     FakeProcesses,
@@ -645,8 +644,7 @@ class TestLXD(TestCase):
         LXD("1", "xenial", "amd64").run(["echo", arg])
 
         expected_args = [
-            ["lxc", "exec", "lp-xenial-amd64", "--",
-             "linux64", "echo", arg.encode("UTF-8") if six.PY2 else arg],
+            ["lxc", "exec", "lp-xenial-amd64", "--", "linux64", "echo", arg],
             ]
         self.assertEqual(
             expected_args,
diff --git a/lpbuildd/tests/fakebuilder.py b/lpbuildd/tests/fakebuilder.py
index 268fd13..24a40b2 100644
--- a/lpbuildd/tests/fakebuilder.py
+++ b/lpbuildd/tests/fakebuilder.py
@@ -9,17 +9,16 @@ __all__ = [
     ]
 
 from collections import defaultdict
+from configparser import (
+    NoOptionError,
+    NoSectionError,
+    )
 import hashlib
 import os
 import shutil
 import stat
 import subprocess
 
-from six.moves.configparser import (
-    NoOptionError,
-    NoSectionError,
-    )
-
 from lpbuildd.target.backend import Backend
 from lpbuildd.util import (
     set_personality,
diff --git a/lpbuildd/tests/test_buildd.py b/lpbuildd/tests/test_buildd.py
index 3cecb5a..9eb421d 100644
--- a/lpbuildd/tests/test_buildd.py
+++ b/lpbuildd/tests/test_buildd.py
@@ -19,9 +19,9 @@ import shutil
 import sys
 import tempfile
 import unittest
+from urllib.request import HTTPBasicAuthHandler
+from xmlrpc.client import ServerProxy
 
-from six.moves.urllib.request import HTTPBasicAuthHandler
-from six.moves.xmlrpc_client import ServerProxy
 import twisted
 
 from lpbuildd.tests.harness import (
diff --git a/lpbuildd/tests/test_builder.py b/lpbuildd/tests/test_builder.py
index 1f08126..aee3e4d 100644
--- a/lpbuildd/tests/test_builder.py
+++ b/lpbuildd/tests/test_builder.py
@@ -10,7 +10,6 @@ import io
 import re
 
 from fixtures import TempDir
-import six
 from testtools import TestCase
 from testtools.deferredruntest import AsynchronousDeferredRunTest
 from twisted.internet import defer
@@ -122,9 +121,7 @@ class TestBuildManager(TestCase):
             "RUN: echo '\N{SNOWMAN}'\n"
             "\N{SNOWMAN}\n".encode(),
             builder._log.getvalue())
-        logged_snowman = '\N{SNOWMAN}' if six.PY3 else '\\u2603'
         self.assertEqual(
-            ["Build log: RUN: echo '%s'" % logged_snowman,
-             "Build log: %s" % logged_snowman],
+            ["Build log: RUN: echo '\N{SNOWMAN}'", "Build log: \N{SNOWMAN}"],
             [re.sub(r".*? \[-\] (.*)", r"\1", line)
              for line in self.log_file.getvalue().splitlines()])
diff --git a/lpbuildd/tests/test_buildrecipe.py b/lpbuildd/tests/test_buildrecipe.py
index 0914c04..32858fa 100644
--- a/lpbuildd/tests/test_buildrecipe.py
+++ b/lpbuildd/tests/test_buildrecipe.py
@@ -17,7 +17,6 @@ from fixtures import (
     MockPatchObject,
     TempDir,
     )
-import six
 from systemfixtures import FakeProcesses
 from testtools import TestCase
 from testtools.matchers import (
@@ -134,7 +133,7 @@ class TestRecipeBuilder(TestCase):
             "grumpy", "main", "PPA", git=True)
         with open(os.path.join(self.builder.work_dir, "recipe"), "w") as f:
             f.write("dummy recipe contents\n")
-        mock_stdout = six.StringIO()
+        mock_stdout = io.StringIO()
         self.useFixture(MockPatch("sys.stdout", mock_stdout))
         self.assertEqual(0, self.builder.buildTree())
         self.assertEqual(
@@ -185,7 +184,7 @@ class TestRecipeBuilder(TestCase):
             fake_brz_build_daily_recipe, name="brz-build-daily-recipe")
         with open(os.path.join(self.builder.work_dir, "recipe"), "w") as f:
             f.write("dummy recipe contents\n")
-        mock_stdout = six.StringIO()
+        mock_stdout = io.StringIO()
         self.useFixture(MockPatch("sys.stdout", mock_stdout))
         self.useFixture(MockPatchObject(
             self.builder, "_is_command_on_path",
@@ -236,7 +235,7 @@ class TestRecipeBuilder(TestCase):
         processes_fixture.add(fake_bzr, name="bzr")
         with open(os.path.join(self.builder.work_dir, "recipe"), "w") as f:
             f.write("dummy recipe contents\n")
-        mock_stdout = six.StringIO()
+        mock_stdout = io.StringIO()
         self.useFixture(MockPatch("sys.stdout", mock_stdout))
         self.useFixture(MockPatchObject(
             self.builder, "_is_command_on_path", return_value=False))
diff --git a/setup.py b/setup.py
index 680e2c5..b1bea46 100755
--- a/setup.py
+++ b/setup.py
@@ -72,7 +72,6 @@ setup(
         # 'python-apt',
         'python-debian',
         'requests',
-        'six',
         'Twisted',
         'zope.interface',
         ],
diff --git a/system-dependencies.txt b/system-dependencies.txt
index f4d4bd4..df43d2b 100644
--- a/system-dependencies.txt
+++ b/system-dependencies.txt
@@ -13,7 +13,6 @@ python3-pylxd
 python3-requests
 python3-responses
 python3-setuptools
-python3-six
 python3-systemfixtures
 python3-testtools
 python3-twisted