← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-spr-change-summary-stringio into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-spr-change-summary-stringio into launchpad:master.

Commit message:
Use io.StringIO in SourcePackageRelease

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/391327

This was only used in SourcePackageRelease.change_summary, and the input is from a Unicode database column.

`io.StringIO(None).getvalue()` returns an empty string, while `StringIO.StringIO(None).getvalue()` returns 'None'.  As a result, we now display nothing rather than the string 'None' for SPRs with no changelog_entry.  Although the rendering of this case as 'None' was enforced by one test (written two years after the underlying code), I think it was essentially accidental and that displaying nothing is better.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-spr-change-summary-stringio into launchpad:master.
diff --git a/lib/lp/soyuz/model/sourcepackagerelease.py b/lib/lp/soyuz/model/sourcepackagerelease.py
index 803a6f7..c01e2e7 100644
--- a/lib/lp/soyuz/model/sourcepackagerelease.py
+++ b/lib/lp/soyuz/model/sourcepackagerelease.py
@@ -8,10 +8,10 @@ __all__ = [
 
 
 import datetime
+import io
 import json
 import operator
 import re
-from StringIO import StringIO
 
 import apt_pkg
 from debian.changelog import (
@@ -379,7 +379,7 @@ class SourcePackageRelease(SQLBase):
         # this regex is copied from apt-listchanges.py courtesy of MDZ
         new_stanza_line = re.compile(
             '^\S+ \((?P<version>.*)\) .*;.*urgency=(?P<urgency>\w+).*')
-        logfile = StringIO(self.changelog_entry)
+        logfile = io.StringIO(self.changelog_entry)
         change = ''
         top_stanza = False
         for line in logfile.readlines():
diff --git a/lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt b/lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt
index 8c49cb1..c944439 100644
--- a/lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt
+++ b/lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt
@@ -292,7 +292,6 @@ The full change log can be viewed as follows:
     0.9
     Pending in breezy-autotest-release
     ...
-    None
     1.0
     Published in breezy-autotest-release
     ...