launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24667
[Merge] ~cjwatson/launchpad-buildd:py3-output-files-bytes into launchpad-buildd:master
Colin Watson has proposed merging ~cjwatson/launchpad-buildd:py3-output-files-bytes into launchpad-buildd:master.
Commit message:
Treat build output files as binary files
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/383345
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:py3-output-files-bytes into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index ee93dfa..6d7e589 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ launchpad-buildd (190) UNRELEASED; urgency=medium
* Ensure that regex patterns with \-escapes are raw strings.
* Adjust X-LXD-mode header construction for Python 3.
* Treat build logs as binary files.
+ * Treat build output files as binary files.
-- Colin Watson <cjwatson@xxxxxxxxxx> Tue, 28 Apr 2020 10:19:27 +0100
diff --git a/lpbuildd/builder.py b/lpbuildd/builder.py
index fc3a0ce..36f01fb 100644
--- a/lpbuildd/builder.py
+++ b/lpbuildd/builder.py
@@ -434,10 +434,10 @@ class Builder(object):
extra_info = 'Error accessing Librarian: %s' % info
self.log(extra_info)
else:
- of = open(cachefile + '.tmp', "w")
+ of = open(cachefile + '.tmp', "wb")
# Upped for great justice to 256k
check_sum = hashlib.sha1()
- for chunk in iter(lambda: f.read(256*1024), ''):
+ for chunk in iter(lambda: f.read(256*1024), b''):
of.write(chunk)
check_sum.update(chunk)
of.close()
@@ -453,12 +453,12 @@ class Builder(object):
def storeFile(self, path):
"""Store the content of the provided path in the file cache."""
- f = open(path)
+ f = open(path, "rb")
tmppath = self.cachePath("storeFile.tmp")
- of = open(tmppath, "w")
+ of = open(tmppath, "wb")
try:
sha1 = hashlib.sha1()
- for chunk in iter(lambda: f.read(256*1024), ''):
+ for chunk in iter(lambda: f.read(256*1024), b''):
sha1.update(chunk)
of.write(chunk)
sha1sum = sha1.hexdigest()
diff --git a/lpbuildd/debian.py b/lpbuildd/debian.py
index 7f8dd92..053b609 100644
--- a/lpbuildd/debian.py
+++ b/lpbuildd/debian.py
@@ -7,6 +7,7 @@
__metaclass__ = type
import base64
+import io
import os
import re
import signal
@@ -119,13 +120,10 @@ class DebianBuildManager(BuildManager):
path = self.getChangesFilename()
self._builder.addWaitingFile(path)
- chfile = open(path, "r")
- try:
+ with io.open(path, "r", errors="replace") as chfile:
for fn in self._parseChangesFile(chfile):
self._builder.addWaitingFile(
get_build_path(self.home, self._buildid, fn))
- finally:
- chfile.close()
def deferGatherResults(self):
"""Gather the results of the build in a thread."""