summaryrefslogtreecommitdiffstats
path: root/pym/portage/exception.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-03-27 13:55:11 -0700
committerZac Medico <zmedico@gentoo.org>2011-03-27 13:55:11 -0700
commit436c4629ffde8089b369fe58180b474a302b6630 (patch)
tree159f586f854dd5ce541918ff8fa935ef85a15351 /pym/portage/exception.py
parent3bfc88f2aed25d4289dafca6c069eae8e71971ea (diff)
downloadportage-436c4629ffde8089b369fe58180b474a302b6630.tar.gz
portage-436c4629ffde8089b369fe58180b474a302b6630.tar.bz2
portage-436c4629ffde8089b369fe58180b474a302b6630.zip
UnsupportedAPIException: handle unicode in EAPI
Normally EAPI doesn't contain unicode, but as in bug #359675, it can contain practically anything if files in /var/db/pkg are corrupt.
Diffstat (limited to 'pym/portage/exception.py')
-rw-r--r--pym/portage/exception.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 64d0f7b0d..789112072 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2004 Gentoo Foundation
+# Copyright 1998-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import signal
@@ -150,13 +150,24 @@ class UnsupportedAPIException(PortagePackageException):
def __init__(self, cpv, eapi):
self.cpv, self.eapi = cpv, eapi
def __str__(self):
+ eapi = self.eapi
+ if not isinstance(eapi, basestring):
+ eapi = str(eapi)
+ eapi = eapi.lstrip("-")
msg = _("Unable to do any operations on '%(cpv)s', since "
"its EAPI is higher than this portage version's. Please upgrade"
" to a portage version that supports EAPI '%(eapi)s'.") % \
- {"cpv": self.cpv, "eapi": str(self.eapi).lstrip("-")}
- return msg
+ {"cpv": self.cpv, "eapi": eapi}
+ return _unicode_decode(msg,
+ encoding=_encodings['content'], errors='replace')
+ if sys.hexversion < 0x3000000:
+
+ __unicode__ = __str__
+ def __str__(self):
+ return _unicode_encode(self.__unicode__(),
+ encoding=_encodings['content'], errors='backslashreplace')
class SignatureException(PortageException):
"""Signature was not present in the checked file"""