Skip to content

autodoc raises an exception if a Python class inherits from io.BufferedReader #8815

@ralhei

Description

@ralhei

Describe the bug
sphinx.ext.autodoc raises an exception if a Python class inherits from io.BufferedReader. Same with io.BufferedWriter. No problem with io.BytesIO or others.

To Reproduce
Steps to reproduce the behavior:

$ pip install sphinx  # obtained version 3.4.3
$ sphinx-quickstart

... answer the questions about version, author,...

Add extensions = ['sphinx.ext.autodoc'] to source/conf.py
Add into index.rst:

.. automodule:: bufferedreader
     :members:

The create a small python module:

$cat > source/bufferedreader.py <<EOF
import io

class MyBufferedReader(io.BufferedReader): 
    """buffer reader class."""

and finally export PYTHONPATH=<path/to/sphinx/source-dir>

Running sphinx-build -E -n -v -b html . ../build from inside the source directory produces the following ouput

WARNING: error while formatting arguments for bufferedreader.MyBufferedReader:
WARNING: error while formatting signature for bufferedreader.MyBufferedReader: Handler <function record_typehints at 0x7f0d3e2c8f28> for event 'autodoc-process-signature' threw an exception (exception: )

Due to this bug the documentation for class MyBufferedReader is not contained in the HTML.

Environment info

  • OS: suse sles 15.1
  • Python version: 3.7.1
  • Sphinx version: 3.4.3
  • Sphinx extensions: sphinx.ext.autodoc

Additional Note
There is no problem for old sphinx 1.8.2 with this issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions