mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#427: fix the encode() method of translation proxies.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user