Such changes are often indications of wrong text handling. While the added code is not harmful, it would be good to check (I haven't checked) if en/decoding shouldn't actually happen at a different site.
Thanks for the attention. I agree that the en/decoding location is the most sensitive thing.
Currently, the Sphinx has to have strings as unicode type at the whole location as much as possible. If sphinx has a grabbing docstring mechanism, it should be better to use it. However there is no such mechanism for now then I suggested to Shirou wakayama (in small bug squash meeting for sphinx in JP) to decode bytes at this location by using ModuleAnalyzer.encoding that is similar way as autodoc's mechanism.
BTW, ... if type of __doc__ is already unicode, it's not necessary to decode. autodoc is checking a type of string (unicode or not) and using sphinx.util.force_decode to decode.
Conclusion, I think the location of decoding is fine, but process is not enough. I'll fix it as:
- doc = doc.decode(enc)
+ if not isinstance(doc, unicode):
+ doc = sphinx.util.force_decode(doc, enc)