summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-18 11:10:56 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-18 11:10:56 -0800
commit1e83f9f2eecfce75db535dd5590a37ea9ddd135d (patch)
treeaf2da9df72ccf136048d8fbe48278f5e7702f668
parentef714a6eff72dec7f4ac2104694f29cdc695db9d (diff)
downloadportage-1e83f9f2eecfce75db535dd5590a37ea9ddd135d.tar.gz
portage-1e83f9f2eecfce75db535dd5590a37ea9ddd135d.tar.bz2
portage-1e83f9f2eecfce75db535dd5590a37ea9ddd135d.zip
localization: always return unicode
-rw-r--r--pym/portage/localization.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/pym/portage/localization.py b/pym/portage/localization.py
index d16c4b131..2815ef5a8 100644
--- a/pym/portage/localization.py
+++ b/pym/portage/localization.py
@@ -1,12 +1,18 @@
# localization.py -- Code to manage/help portage localization.
-# Copyright 2004 Gentoo Foundation
+# Copyright 2004-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+from portage import _unicode_decode
# We define this to make the transition easier for us.
def _(mystr):
- return mystr
-
+ """
+ Always returns unicode, regardless of the input type. This is
+ helpful for avoiding UnicodeDecodeError from __str__() with
+ Python 2, by ensuring that string format operations invoke
+ __unicode__() instead of __str__().
+ """
+ return _unicode_decode(mystr)
def localization_example():
# Dict references allow translators to rearrange word order.