launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24382
[Merge] ~cjwatson/launchpad:distroseries-createqueueentry-bytes into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:distroseries-createqueueentry-bytes into launchpad:master.
Commit message:
Make DistroSeries.createQueueEntry take changesfilecontent as bytes
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/379861
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:distroseries-createqueueentry-bytes into launchpad:master.
diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py
index 8fd5616..d94fd34 100644
--- a/lib/lp/archivepublisher/tests/test_publisher.py
+++ b/lib/lp/archivepublisher/tests/test_publisher.py
@@ -449,7 +449,7 @@ class TestPublisherSeries(TestNativePublishingBase):
bin_i386.name, bin_i386.version, build_i386.arch_tag)
pu_i386 = self.addPackageUpload(
build_i386.archive, build_i386.distro_arch_series.distroseries,
- build_i386.pocket, changes_file_content='anything',
+ build_i386.pocket, changes_file_content=b'anything',
changes_file_name=changes_file_name,
upload_status=PackageUploadStatus.ACCEPTED)
pu_i386.addBuild(build_i386)
diff --git a/lib/lp/archiveuploader/tests/static-translations.txt b/lib/lp/archiveuploader/tests/static-translations.txt
index 41aa56c..a6e9ef2 100644
--- a/lib/lp/archiveuploader/tests/static-translations.txt
+++ b/lib/lp/archiveuploader/tests/static-translations.txt
@@ -40,7 +40,7 @@ publishing behaviour using a mock PackageUploadCustom object:
>>> bat = getUtility(IDistributionSet)['ubuntu']['breezy-autotest']
>>> package_upload = bat.createQueueEntry(
... pocket=PackagePublishingPocket.RELEASE, changesfilename="test",
- ... changesfilecontent="test",
+ ... changesfilecontent=b"test",
... archive=bat.main_archive)
>>> custom_upload = MockPackageUploadCustom()
>>> custom_upload.packageupload = package_upload
diff --git a/lib/lp/registry/interfaces/distroseries.py b/lib/lp/registry/interfaces/distroseries.py
index 19233a3..2d84906 100644
--- a/lib/lp/registry/interfaces/distroseries.py
+++ b/lib/lp/registry/interfaces/distroseries.py
@@ -787,7 +787,7 @@ class IDistroSeriesPublic(
:param changesfilename: Name for the upload's .changes file. You may
specify a changes file by passing both `changesfilename` and
`changesfilecontent`, or by passing `changes_file_alias`.
- :param changesfilecontent: Text for the changes file. It will be
+ :param changesfilecontent: Bytes for the changes file. It will be
signed and stored in the Librarian. Must be passed together with
`changesfilename`; alternatively, you may provide a
`changes_file_alias` to replace both of these.
diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py
index af9df05..51dbeea 100644
--- a/lib/lp/registry/model/distroseries.py
+++ b/lib/lp/registry/model/distroseries.py
@@ -13,7 +13,7 @@ __all__ = [
]
import collections
-from cStringIO import StringIO
+from io import BytesIO
from operator import attrgetter
import apt_pkg
@@ -1385,7 +1385,7 @@ class DistroSeries(SQLBase, BugTargetBase, HasSpecificationsMixin,
changes_file_alias = getUtility(ILibraryFileAliasSet).create(
changesfilename, len(changesfilecontent),
- StringIO(changesfilecontent), 'text/plain',
+ BytesIO(changesfilecontent), 'text/plain',
restricted=archive.private)
return PackageUpload(
diff --git a/lib/lp/soyuz/browser/tests/test_build_views.py b/lib/lp/soyuz/browser/tests/test_build_views.py
index 4c00cc3..8e13a22 100644
--- a/lib/lp/soyuz/browser/tests/test_build_views.py
+++ b/lib/lp/soyuz/browser/tests/test_build_views.py
@@ -191,7 +191,7 @@ class TestBuildViews(TestCaseWithFactory):
self.assertFalse(build_view.has_published_binaries)
package_upload = build.distro_series.createQueueEntry(
PackagePublishingPocket.UPDATES, build.archive,
- 'changes.txt', 'my changes')
+ 'changes.txt', b'my changes')
# Old SQL Object: creating it, adds it automatically to the store.
PackageUploadBuild(packageupload=package_upload, build=build)
self.assertEqual(package_upload.status.name, 'NEW')
diff --git a/lib/lp/soyuz/browser/tests/test_queue.py b/lib/lp/soyuz/browser/tests/test_queue.py
index 0e08739..7c26c09 100644
--- a/lib/lp/soyuz/browser/tests/test_queue.py
+++ b/lib/lp/soyuz/browser/tests/test_queue.py
@@ -81,7 +81,9 @@ class TestAcceptRejectQueueUploads(TestCaseWithFactory):
self.partner_archive = distribution.getArchiveByComponent('partner')
# Get some sample changes file content for the new uploads.
- with open(datadir('suite/bar_1.0-1/bar_1.0-1_source.changes')) as cf:
+ with open(
+ datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
+ 'rb') as cf:
changes_file_content = cf.read()
self.partner_spr = self.makeSPR(
diff --git a/lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt b/lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt
index a40da11..d4c42cc 100644
--- a/lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt
+++ b/lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt
@@ -57,7 +57,7 @@ for close_bugs_for_queue_item to operate on.
... pocket=PackagePublishingPocket.RELEASE,
... archive=None, distroseries=None):
... """Create a PackageUpload record."""
- ... changes = changes_template % fixing_text
+ ... changes = (changes_template % fixing_text).encode('UTF-8')
... if distroseries is None:
... distroseries = ubuntu_hoary
... if archive is None:
diff --git a/lib/lp/soyuz/doc/distribution.txt b/lib/lp/soyuz/doc/distribution.txt
index 7186b82..7852fc8 100644
--- a/lib/lp/soyuz/doc/distribution.txt
+++ b/lib/lp/soyuz/doc/distribution.txt
@@ -139,7 +139,7 @@ Create a NEW PackageUpload record for cprov PPA:
>>> login('mark@xxxxxxxxxxx')
>>> queue = hoary.createQueueEntry(
... pocket=PackagePublishingPocket.RELEASE, archive=cprov.archive,
- ... changesfilename='foo', changesfilecontent='bar')
+ ... changesfilename='foo', changesfilecontent=b'bar')
>>> queue.status.name
'NEW'
diff --git a/lib/lp/soyuz/doc/distroseriesqueue.txt b/lib/lp/soyuz/doc/distroseriesqueue.txt
index 1c0245d..bb859f5 100644
--- a/lib/lp/soyuz/doc/distroseriesqueue.txt
+++ b/lib/lp/soyuz/doc/distroseriesqueue.txt
@@ -504,7 +504,7 @@ breezy-autotest context. It also becomes part of the lookup results.
>>> candidate_queue = breezy_autotest.createQueueEntry(
... PackagePublishingPocket.RELEASE,
... breezy_autotest.main_archive,
- ... 'pmount_0.1-1_source.changes', 'some content')
+ ... 'pmount_0.1-1_source.changes', b'some content')
>>> matching_pmount = pmount.getVersion('0.1-1')
>>> unused = candidate_queue.addSource(
... matching_pmount.sourcepackagerelease)
@@ -696,7 +696,7 @@ Filtering by custom_type. We need to add some custom uploads to show this.
>>> def add_static_xlat_upload():
... upload = warty.createQueueEntry(
... pocket=PackagePublishingPocket.RELEASE,
- ... changesfilename="test", changesfilecontent="test",
+ ... changesfilename="test", changesfilecontent=b"test",
... archive=warty.main_archive)
... arbitrary_file = factory.makeLibraryFileAlias()
... upload.addCustom(arbitrary_file, static_xlat)
diff --git a/lib/lp/soyuz/scripts/tests/test_copypackage.py b/lib/lp/soyuz/scripts/tests/test_copypackage.py
index 29987b5..b5bd4c6 100644
--- a/lib/lp/soyuz/scripts/tests/test_copypackage.py
+++ b/lib/lp/soyuz/scripts/tests/test_copypackage.py
@@ -1684,7 +1684,8 @@ class TestDoDirectCopy(BaseDoCopyTests, TestCaseWithFactory):
changes_file_name = '%s_%s_%s.changes' % (
lazy_bin.name, lazy_bin.version, build_i386.arch_tag)
self.test_publisher.addPackageUpload(
- archive, nobby, build_i386.pocket, changes_file_content='anything',
+ archive, nobby, build_i386.pocket,
+ changes_file_content=b'anything',
changes_file_name=changes_file_name)
# Make the new library files available.
@@ -1991,8 +1992,8 @@ class TestCopyClosesBugs(TestCaseWithFactory):
def createSource(self, version, archive, pocket, bug_id):
changes_template = (
- "Format: 1.7\n"
- "Launchpad-bugs-fixed: %s\n")
+ b"Format: 1.7\n"
+ b"Launchpad-bugs-fixed: %s\n")
changes_file_content = changes_template % bug_id
source = self.test_publisher.getPubSource(
sourcename='buggy-source', version=version,
diff --git a/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py b/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py
index be2e3ff..22b7a74 100644
--- a/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py
+++ b/lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py
@@ -310,7 +310,7 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
distribution=parent.distribution)
upload = other_series.createQueueEntry(
PackagePublishingPocket.RELEASE,
- other_series.main_archive, 'foo.changes', 'bar')
+ other_series.main_archive, 'foo.changes', b'bar')
# Create a binary package upload for this upload.
upload.addBuild(self.factory.makeBinaryPackageBuild())
child = self.factory.makeDistroSeries()
@@ -487,7 +487,7 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
for pocket in pockets:
parent, parent_das = self.setupParent()
upload = parent.createQueueEntry(
- pocket, parent.main_archive, 'foo.changes', 'bar')
+ pocket, parent.main_archive, 'foo.changes', b'bar')
# Create a binary package upload for this upload.
upload.addBuild(self.factory.makeBinaryPackageBuild())
child = self.factory.makeDistroSeries()
@@ -508,7 +508,7 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
for pocket in pockets:
parent, parent_das = self.setupParent()
upload = parent.createQueueEntry(
- pocket, parent.main_archive, 'foo.changes', 'bar')
+ pocket, parent.main_archive, 'foo.changes', b'bar')
# Create a binary package upload for this upload.
upload.addBuild(self.factory.makeBinaryPackageBuild())
child = self.factory.makeDistroSeries()
@@ -572,7 +572,7 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
parent, parent_das = self.setupParent()
upload = parent.createQueueEntry(
PackagePublishingPocket.RELEASE,
- parent.main_archive, 'foo.changes', 'bar')
+ parent.main_archive, 'foo.changes', b'bar')
# Create a source package upload for this upload.
upload.addSource(self.factory.makeSourcePackageRelease())
child = self.factory.makeDistroSeries()
@@ -595,7 +595,7 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
# packageset 'packageset2'.
upload = parent.createQueueEntry(
PackagePublishingPocket.RELEASE,
- parent.main_archive, 'foo.changes', 'bar')
+ parent.main_archive, 'foo.changes', b'bar')
upload.addBuild(self.factory.makeBinaryPackageBuild(
distroarchseries=parent_das,
source_package_release=spr2))
@@ -619,7 +619,7 @@ class TestInitializeDistroSeries(InitializationHelperTestCase):
# packageset 'packageset2'.
upload = parent.createQueueEntry(
PackagePublishingPocket.RELEASE,
- parent.main_archive, 'foo.changes', 'bar')
+ parent.main_archive, 'foo.changes', b'bar')
upload.addBuild(self.factory.makeBinaryPackageBuild(
distroarchseries=parent_das,
source_package_release=spr1))
diff --git a/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt b/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt
index 1bd9bdb..0919a00 100644
--- a/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt
+++ b/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt
@@ -31,7 +31,7 @@ XXX: noodles 2009-01-16 bug 317863: move this into the STP.
>>> build = getUtility(IBinaryPackageBuildSet).getByID(2)
>>> package_upload = build.distro_series.createQueueEntry(
... PackagePublishingPocket.UPDATES, build.archive,
- ... 'changes.txt', 'my changes')
+ ... 'changes.txt', b'my changes')
>>> package_upload_build = PackageUploadBuild(
... packageupload =package_upload,
... build=build)
diff --git a/lib/lp/soyuz/stories/soyuz/xx-build-record.txt b/lib/lp/soyuz/stories/soyuz/xx-build-record.txt
index 6f4aeb4..17e0614 100644
--- a/lib/lp/soyuz/stories/soyuz/xx-build-record.txt
+++ b/lib/lp/soyuz/stories/soyuz/xx-build-record.txt
@@ -318,7 +318,7 @@ appropriate 'Build status' section the user will see 2 new sections,
... PackagePublishingPocket.RELEASE,
... stp.distroseries.main_archive,
... 'testing_1.0_all.changes',
- ... 'nothing-special')
+ ... b'nothing-special')
>>> unused = upload.addBuild(build)
>>> logout()
diff --git a/lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt b/lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt
index b2bc537..4e2ec21 100644
--- a/lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt
+++ b/lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt
@@ -289,7 +289,7 @@ Upload a new "bar" source so we can accept it later.
>>> from lp.archiveuploader.tests import datadir
>>> changes_file = open(
- ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'))
+ ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'), 'rb')
>>> changes_file_content = changes_file.read()
>>> changes_file.close()
diff --git a/lib/lp/soyuz/stories/webservice/xx-packageupload.txt b/lib/lp/soyuz/stories/webservice/xx-packageupload.txt
index 5546f4a..f01a270 100644
--- a/lib/lp/soyuz/stories/webservice/xx-packageupload.txt
+++ b/lib/lp/soyuz/stories/webservice/xx-packageupload.txt
@@ -64,7 +64,7 @@ First, insert some data to retrieve:
>>> warty_series = getUtility(IDistributionSet)['ubuntu']['warty']
>>> upload = warty_series.createQueueEntry(
... pocket=PackagePublishingPocket.RELEASE, changesfilename="test",
- ... changesfilecontent="test", archive=warty_series.main_archive)
+ ... changesfilecontent=b"test", archive=warty_series.main_archive)
>>> arbitrary_file = factory.makeLibraryFileAlias(filename="custom1")
>>> custom = upload.addCustom(
... arbitrary_file, PackageUploadCustomFormat.STATIC_TRANSLATIONS)
diff --git a/lib/lp/soyuz/tests/test_packageupload.py b/lib/lp/soyuz/tests/test_packageupload.py
index 5afc59a..0908afd 100644
--- a/lib/lp/soyuz/tests/test_packageupload.py
+++ b/lib/lp/soyuz/tests/test_packageupload.py
@@ -124,7 +124,7 @@ class PackageUploadTestCase(TestCaseWithFactory):
# Get some sample changes file content for the new upload.
changes_file = open(
- datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'))
+ datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'), 'rb')
changes_file_content = changes_file.read()
changes_file.close()
diff --git a/lib/lp/soyuz/tests/test_publishing.py b/lib/lp/soyuz/tests/test_publishing.py
index c63005f..c29028e 100644
--- a/lib/lp/soyuz/tests/test_publishing.py
+++ b/lib/lp/soyuz/tests/test_publishing.py
@@ -516,7 +516,7 @@ class SoyuzTestPublisher:
if new_version is None:
new_version = version
changesfile_content = ''
- with open(changesfile_path, 'r') as handle:
+ with open(changesfile_path, 'rb') as handle:
changesfile_content = handle.read()
source = self.getPubSource(
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index d706d92..85a05b6 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -3621,7 +3621,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
if changes_filename is None:
changes_filename = self.getUniqueString("changesfilename")
if changes_file_content is None:
- changes_file_content = self.getUniqueString("changesfilecontent")
+ changes_file_content = self.getUniqueBytes(b"changesfilecontent")
if pocket is None:
pocket = PackagePublishingPocket.RELEASE
package_upload = distroseries.createQueueEntry(