launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24678
[Merge] ~cjwatson/launchpad-buildd:py3-buildrecipe into launchpad-buildd:master
Colin Watson has proposed merging ~cjwatson/launchpad-buildd:py3-buildrecipe into launchpad-buildd:master.
Commit message:
Make buildrecipe compatible with Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/383446
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:py3-buildrecipe into launchpad-buildd:master.
diff --git a/bin/buildrecipe b/bin/buildrecipe
index 88e75c0..d20820a 100755
--- a/bin/buildrecipe
+++ b/bin/buildrecipe
@@ -8,6 +8,7 @@ from __future__ import print_function
__metaclass__ = type
+import io
from optparse import OptionParser
import os
import pwd
@@ -64,7 +65,9 @@ class RecipeBuilder:
bzr-based recipe.
"""
self.build_id = build_id
- self.author_name = author_name.decode('utf-8')
+ if isinstance(author_name, bytes):
+ author_name = author_name.decode('utf-8')
+ self.author_name = author_name
self.author_email = author_email
self.archive_purpose = archive_purpose
self.component = component
@@ -159,19 +162,24 @@ class RecipeBuilder:
source_dir = os.path.join(
self.chroot_path, self.source_dir_relative.lstrip('/'))
changelog = os.path.join(source_dir, 'debian/changelog')
- return open(changelog, 'r').readline().split(' ')[0]
+ return io.open(
+ changelog, 'r', errors='replace').readline().split(' ')[0]
def getSourceControl(self):
"""Return the parsed source control stanza from the source tree."""
source_dir = os.path.join(
self.chroot_path, self.source_dir_relative.lstrip('/'))
- with open(os.path.join(source_dir, 'debian/control')) as control_file:
+ # Open as bytes to allow debian.deb822 to apply its own encoding
+ # handling. We'll get text back from it.
+ with open(
+ os.path.join(source_dir, 'debian/control'),
+ 'rb') as control_file:
# Don't let Deb822.iter_paragraphs use apt_pkg.TagFile
# internally, since that only handles real tag files and not the
# slightly more permissive syntax of debian/control which also
# allows comments.
- return Deb822.iter_paragraphs(
- control_file, use_apt_pkg=False).next()
+ return next(Deb822.iter_paragraphs(
+ control_file, use_apt_pkg=False))
def makeDummyDsc(self, package):
control = self.getSourceControl()
diff --git a/debian/changelog b/debian/changelog
index 1995088..7b8c649 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ launchpad-buildd (190) UNRELEASED; urgency=medium
* Treat build logs as binary files.
* Treat build output files as binary files.
* Treat intltool-related files as binary files.
+ * Make buildrecipe compatible with Python 3.
-- Colin Watson <cjwatson@xxxxxxxxxx> Tue, 28 Apr 2020 10:19:27 +0100