summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-03-08 15:04:39 +0100
committerJulian Andres Klode <jak@debian.org>2010-03-08 15:04:39 +0100
commit7ebf48f29064579cf4752aa5bf9c4663b49c2792 (patch)
tree47b5d8b69dea5092457cab88b36168ee62845b71
parent4b434cde19d25e2acc238699834f1a2a72540ca2 (diff)
downloadpython-apt-7ebf48f29064579cf4752aa5bf9c4663b49c2792.tar.gz
apt/package.py: Always return unicode strings in Package.get_changelog (Closes: #572998).
-rw-r--r--apt/package.py20
-rw-r--r--debian/changelog1
2 files changed, 14 insertions, 7 deletions
diff --git a/apt/package.py b/apt/package.py
index 7c739aab..0c026504 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -981,7 +981,7 @@ class Package(object):
which if set, prevents the download.
"""
# Return a cached changelog if available
- if self._changelog != "":
+ if self._changelog != u"":
return self._changelog
if uri is None:
@@ -996,7 +996,8 @@ class Package(object):
"/%(src_section)s/%(prefix)s/%(src_pkg)s" \
"/%(src_pkg)s_%(src_ver)s/changelog"
else:
- return _("The list of changes is not available")
+ res = _("The list of changes is not available")
+ return res if isinstance(res, unicode) else res.decode("utf-8")
# get the src package name
src_pkg = self.candidate.source_name
@@ -1066,15 +1067,15 @@ class Package(object):
# Check if the download was canceled
if cancel_lock and cancel_lock.isSet():
- return ""
+ return u""
changelog_file = urllib2.urlopen(uri)
# do only get the lines that are new
- changelog = ""
+ changelog = u""
regexp = "^%s \((.*)\)(.*)$" % (re.escape(src_pkg))
while True:
# Check if the download was canceled
if cancel_lock and cancel_lock.isSet():
- return ""
+ return u""
# Read changelog line by line
line_raw = changelog_file.readline()
if line_raw == "":
@@ -1094,6 +1095,7 @@ class Package(object):
changelog_ver = match.group(1)
if changelog_ver and ":" in changelog_ver:
changelog_ver = changelog_ver.split(":", 1)[1]
+
if (installed and apt_pkg.version_compare(
changelog_ver, installed) <= 0):
break
@@ -1103,17 +1105,21 @@ class Package(object):
# Print an error if we failed to extract a changelog
if len(changelog) == 0:
changelog = _("The list of changes is not available")
+ if not isinstance(changelog, unicode):
+ changelog = changelog.decode("utf-8")
self._changelog = changelog
except urllib2.HTTPError:
- return _("The list of changes is not available yet.\n\n"
+ res = _("The list of changes is not available yet.\n\n"
"Please use http://launchpad.net/ubuntu/+source/%s/"
"%s/+changelog\n"
"until the changes become available or try again "
"later.") % (src_pkg, src_ver)
+ return res if isinstance(res, unicode) else res.decode("utf-8")
except (IOError, httplib.BadStatusLine):
- return _("Failed to download the list of changes. \nPlease "
+ res = _("Failed to download the list of changes. \nPlease "
"check your Internet connection.")
+ return res if isinstance(res, unicode) else res.decode("utf-8")
finally:
socket.setdefaulttimeout(timeout)
return self._changelog
diff --git a/debian/changelog b/debian/changelog
index 77e1dde1..ce6ddf7f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ python-apt (0.7.93.4) unstable; urgency=low
'>>' and '<' equal to '<<' (compatibility).
- Use the binary package version in Version.fetch_source() if the
source version is not specified (i.e. in the normal case).
+ - Always return unicode strings in Package.get_changelog (Closes: #572998).
* apt/progress/text.py:
- Drop InstallProgress, it's useless to keep this alias around.
* apt/progress/old.py: