1. Georg Brandl
  2. sphinx
  3. Pull requests

Pull requests

#270 Merged
Repository
r_rudi
Branch
default
Repository
birkenfeld
Branch
default

if code is not unicode, change to unicode in ext/graphviz.py.

Author
  1. Shirou wakayama
Reviewers
Description

Unicode check using six.text_type.

I think it could fix issue #1131 and issue #1533.

Comments (4)

  1. Georg Brandl repo owner

    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.

    1. Takayuki Shimizukawa

      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)
      

      Thank!