Skip to content

Incorrect encoding of doc strings of properties inherited from class defined in different module containing correct encoding declaration #1270

@shimizukawa

Description

@shimizukawa

Sphinx uses incorrect encoding of doc strings of properties inherited from class defined in different module containing correct encoding declaration.

This issue is similar to issue #1185. Before commit 56e385ec3f5b, there was an exception, now Sphinx uses incorrect encoding.

Example (reproducible with Python 2):

$ cat docs/conf.py
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))

extensions = ["sphinx.ext.autodoc"]
master_doc = "index"
$ cat docs/index.rst
documentation
=============

.. autoclass:: module1.Class1
    :inherited-members:

.. autoclass:: module2.Class2
    :inherited-members:
$ cat module1.py
# -*- coding: utf-8 -*-

class Class1:
    def get_myproperty(self):
        """doc string of get_myproperty. ś"""
        return 0

    def set_myproperty(self, value):
        """doc string of set_myproperty. ś"""
        pass

    myproperty = property(get_myproperty, set_myproperty, doc="doc string of myproperty. ś")
$ cat module2.py
import module1

class Class2(module1.Class1):
    pass

module1.py contains utf-8 encoding declaration and defines doc strings with "ś" character. module2.py defines a class, which inherits from class defined in module1.py.

index.html generated by Sphinx running under Python 2 contains:

class module1.Class1
    get_myproperty()
        doc string of get_myproperty. ś
    myproperty None
        doc string of myproperty. ś
    set_myproperty(value)
        doc string of set_myproperty. ś

class module2.Class2
    get_myproperty()
        doc string of get_myproperty. ś
    myproperty None
        doc string of myproperty. �
    set_myproperty(value)
        doc string of set_myproperty. ś

The documentation of module2.Class2.myproperty contains "Å�" character instead of "ś".


Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions