#427: fix the encode() method of translation proxies.

This commit is contained in:
Georg Brandl
2010-05-27 00:06:48 +02:00
parent 0d4c3a31b6
commit b3524a8697
2 changed files with 14 additions and 2 deletions

View File

@@ -41,6 +41,18 @@ class _TranslationProxy(UserString.UserString, object):
data = property(lambda x: x._func(*x._args))
# replace function from UserString; it instantiates a self.__class__
# for the encoding result
def encode(self, encoding=None, errors=None):
if encoding:
if errors:
return self.data.encode(encoding, errors)
else:
return self.data.encode(encoding)
else:
return self.data.encode()
def __contains__(self, key):
return key in self.data

View File

@@ -170,8 +170,8 @@ class IndexBuilder(object):
otypes[domainname, type] = i
otype = domain.object_types.get(type)
if otype:
# use str() to fire translation proxies
onames[i] = str(domain.get_type_name(otype))
# use unicode() to fire translation proxies
onames[i] = unicode(domain.get_type_name(otype))
else:
onames[i] = type
pdict[name] = (fn2index[docname], i, prio)