Skip to content

Fix autodoc IndexError on class with custom __module__ on Python 3.14#14360

Open
joshuaswanson wants to merge 1 commit intosphinx-doc:masterfrom
joshuaswanson:fix/autodoc-indexerror-type-comment
Open

Fix autodoc IndexError on class with custom __module__ on Python 3.14#14360
joshuaswanson wants to merge 1 commit intosphinx-doc:masterfrom
joshuaswanson:fix/autodoc-indexerror-type-comment

Conversation

@joshuaswanson
Copy link
Copy Markdown

Fixes #14345.

On Python 3.14, inspect.getsource on a class with a custom __module__ can return "\n" instead of raising OSError. ast.parse("\n") then produces an empty module body, and module.body[0] raises IndexError. Added IndexError to the existing except clause in get_type_comment so it returns None gracefully, matching the existing behavior for OSError and TypeError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autodoc "list index out of range" error on class with custom __module__

1 participant