-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Labels
Description
Describe the bug
In pytest we have class (edited for clarity)
# Defined in `_pytest.warning_types`, re-exported from `pytest`.
class PytestUnraisableExceptionWarning(PytestWarning):
__module__ = "pytest"When building the docs on Python 3.14, we get a warning (which leads to an error due to -Werror):
error while formatting arguments for pytest.PytestUnraisableExceptionWarning: list index out of range [autodoc]
From what I can see, this happens in get_type_comment. It runs inspect.getsource on PytestUnraisableExceptionWarning, and while in Python 3.13 it used to raise OSError due to the "wrong" __module__, in Python 3.14 it seems like it just returns "\n". Then Sphinx runs ast.parse("\n"), which returns an empty Module and sphinx then accesses module.body[0] which fails. So adding an IndexError to the try-catch fixes the problem (what we'll do as a workaround).
How to Reproduce
A bit short of time to produce an MRE, sorry. I can do it later if needed.
The steps to reproduce are:
- `git clone https://github.com/pytest-dev/pytest
git checkout 960ddc6f67d7a37b8390f260f8ded2049f8a28de(current main)- Change
basepython = python3.13tobasepython = python3.14intox.iniin the[docs]environment - Run
tox -e docs
Environment Information
Platform: linux; (Linux-6.18.13-arch1-1-x86_64-with-glibc2.43)
Python version: 3.14.3 (main, Feb 13 2026, 15:31:44) [GCC 15.2.1 20260209])
Python implementation: CPython
Sphinx version: 9.1.0
Docutils version: 0.22.4
Jinja2 version: 3.1.6
Pygments version: 2.19.2
Sphinx extensions
sphinx-basic-ng 1.0.0b2
sphinx-inline-tabs 2025.12.21.14
sphinx-issues 6.0.0
sphinx-removed-in 0.2.3
sphinxcontrib-applehelp 2.0.0
sphinxcontrib-devhelp 2.0.0
sphinxcontrib-htmlhelp 2.1.0
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 2.0.0
sphinxcontrib-serializinghtml 2.0.0
sphinxcontrib-svg2pdfconverter 2.1.0
sphinxcontrib-towncrier 0.5.0a0
sphinxcontrib-trio 1.2.0
extensions = [
"pygments_pytest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx_removed_in",
"sphinx_inline_tabs",
"sphinxcontrib_trio",
"sphinxcontrib.towncrier.ext",
"sphinx_issues",
]Additional context
No response
Reactions are currently unavailable