Bug 2353144 - python-sphinx fails to build with Python 3.14: multiple test failures
Summary: python-sphinx fails to build with Python 3.14: multiple test failures
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-sphinx
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karolina Surma
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2025-03-18 11:25 UTC by Karolina Surma
Modified: 2025-04-09 09:31 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-04-09 09:31:58 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2025-03-18 11:25:07 UTC
python-sphinx fails to build with Python 3.14.0a6.

_______________________________ test_enum_class ________________________________

app = <SphinxTestApp buildername='html'>
autodoc_enum_options = {'members': None, 'undoc-members': None}

    @pytest.mark.sphinx('html', testroot='ext-autodoc')
    def test_enum_class(app, autodoc_enum_options):
        fmt = _EnumFormatter('EnumCls')
        options = autodoc_enum_options | {'private-members': None}
    
        actual = do_autodoc(app, 'class', fmt.target, options)
>       assert list(actual) == [
            *fmt.brief('this is enum class'),
            *fmt.method(
                'say_goodbye', 'a classmethod says good-bye to you.', 'classmethod'
            ),
            *fmt.method('say_hello', 'a method says hello to you.'),
            *fmt.member('val1', 12, 'doc for val1'),
            *fmt.member('val2', 23, 'doc for val2'),
            *fmt.member('val3', 34, 'doc for val3'),
            *fmt.member('val4', 34, ''),  # val4 is alias of val3
        ]
E       AssertionError: assert ['', '.. py:c...ass', '', ...] == ['', '.. py:c...ass', '', ...]
E         
E         At index 1 diff: '.. py:class:: EnumCls(*values)' != '.. py:class:: EnumCls(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)'
E         Use -v to get more diff

tests/test_extensions/test_ext_autodoc.py:1614: AssertionError

_________________________ test_autodoc_typehints_none __________________________

app = <SphinxTestApp buildername='html'>

    @pytest.mark.sphinx(
        'html',
        testroot='ext-autodoc',
        confoverrides={'autodoc_typehints': 'none'},
    )
    def test_autodoc_typehints_none(app):
        if sys.version_info[:2] >= (3, 13):
            type_ppp = 'pathlib._local.PurePosixPath'
        else:
            type_ppp = 'pathlib.PurePosixPath'
        options = {
            'members': None,
            'undoc-members': None,
        }
        actual = do_autodoc(app, 'module', 'target.typehints', options)
>       assert list(actual) == [
            '',
            '.. py:module:: target.typehints',
            '',
            '',
            '.. py:data:: CONST1',
            '   :module: target.typehints',
            '',
            '',
            '.. py:data:: CONST2',
            '   :module: target.typehints',
            '   :value: 1',
            '',
            '   docstring',
            '',
            '',
            '.. py:data:: CONST3',
            '   :module: target.typehints',
            "   :value: PurePosixPath('/a/b/c')",
            '',
            '   docstring',
            '',
            '',
            '.. py:class:: Math(s, o=None)',
            '   :module: target.typehints',
            '',
            '',
            '   .. py:attribute:: Math.CONST1',
            '      :module: target.typehints',
            '',
            '',
            '   .. py:attribute:: Math.CONST2',
            '      :module: target.typehints',
            '      :value: 1',
            '',
            '',
            '   .. py:attribute:: Math.CONST3',
            '      :module: target.typehints',
            "      :value: PurePosixPath('/a/b/c')",
            '',
            '',
            '   .. py:method:: Math.decr(a, b=1)',
            '      :module: target.typehints',
            '',
            '',
            '   .. py:method:: Math.horse(a, b)',
            '      :module: target.typehints',
            '',
            '',
            '   .. py:method:: Math.incr(a, b=1)',
            '      :module: target.typehints',
            '',
            '',
            '   .. py:method:: Math.nothing()',
            '      :module: target.typehints',
            '',
            '',
            '   .. py:property:: Math.path',
            '      :module: target.typehints',
            '',
            '',
            '   .. py:property:: Math.prop',
            '      :module: target.typehints',
            '',
            '',
            '.. py:class:: NewAnnotation(i)',
            '   :module: target.typehints',
            '',
            '',
            '.. py:class:: NewComment(i)',
            '   :module: target.typehints',
            '',
            '',
            '.. py:class:: SignatureFromMetaclass(a)',
            '   :module: target.typehints',
            '',
            '',
            '.. py:class:: T',
            '   :module: target.typehints',
            '',
            '   docstring',
            '',
            f"   alias of TypeVar('T', bound=\\ :py:class:`~{type_ppp}`)",
            '',
            '',
            '.. py:function:: complex_func(arg1, arg2, arg3=None, *args, **kwargs)',
            '   :module: target.typehints',
            '',
            '',
            '.. py:function:: decr(a, b=1)',
            '   :module: target.typehints',
            '',
            '',
            '.. py:function:: incr(a, b=1)',
            '   :module: target.typehints',
            '',
            '',
            '.. py:function:: missing_attr(c, a, b=None)',
            '   :module: target.typehints',
            '',
            '',
            '.. py:function:: tuple_args(x)',
            '   :module: target.typehints',
            '',
        ]
E       assert ['', '.. py:m...pehints', ...] == ['', '.. py:m...pehints', ...]
E         
E         At index 81 diff: "   alias of TypeVar('T', bound=\\ :py:class:`~pathlib.PurePosixPath`)" != "   alias of TypeVar('T', bound=\\ :py:class:`~pathlib._local.PurePosixPath`)"
E         Use -v to get more diff

tests/test_extensions/test_ext_autodoc_configs.py:840: AssertionError

_____________ test_autodoc_typehints_description_and_type_aliases ______________

app = <SphinxTestApp buildername='text'>

    @pytest.mark.sphinx(
        'text',
        testroot='ext-autodoc',
        srcdir='autodoc_typehints_description_and_type_aliases',
        confoverrides={
            'autodoc_typehints': 'description',
            'autodoc_type_aliases': {'myint': 'myint'},
        },
    )
    def test_autodoc_typehints_description_and_type_aliases(app):
        with overwrite_file(
            app.srcdir / 'autodoc_type_aliases.rst',
            '.. autofunction:: target.autodoc_type_aliases.sum',
        ):
            app.build()
        context = (app.outdir / 'autodoc_type_aliases.txt').read_text(encoding='utf8')
>       assert context == (
            'target.autodoc_type_aliases.sum(x, y)\n'
            '\n'
            '   docstring\n'
            '\n'
            '   Parameters:\n'
            '      * **x** (*myint*)\n'
            '\n'
            '      * **y** (*myint*)\n'
            '\n'
            '   Return type:\n'
            '      myint\n'
        )
E       AssertionError: assert 'target.autod...\n      int\n' == 'target.autod...      myint\n'
E         
E         Skipping 74 identical leading characters in diff, use -v to show
E         - * **x** (*myint*)
E         ?           --
E         + * **x** (*int*)
E           
E         -       * **y** (*myint*)...
E         
E         ...Full output truncated (7 lines hidden), use '-vv' to show

________ test_autosummary_generate_content_for_module_imported_members _________

app = <SphinxTestApp buildername='html'>

    @pytest.mark.sphinx('html', testroot='ext-autosummary')
    def test_autosummary_generate_content_for_module_imported_members(app):
        import autosummary_dummy_module
    
        template = Mock()
    
        generate_autosummary_content(
            'autosummary_dummy_module',
            autosummary_dummy_module,
            None,
            template,
            None,
            True,
            app,
            False,
            {},
        )
        assert template.render.call_args[0][0] == 'module'
    
        context = template.render.call_args[0][1]
        assert context['members'] == [
            'CONSTANT1',
            'CONSTANT2',
            'Class',
            'Exc',
            'Foo',
            'Union',
            '_Baz',
            '_Exc',
            '__all__',
            '__builtins__',
            '__cached__',
            '__doc__',
            '__file__',
            '__loader__',
            '__name__',
            '__package__',
            '__spec__',
            '_quux',
            'bar',
            'considered_as_imported',
            'non_imported_member',
            'path',
            'quuz',
            'qux',
        ]
        assert context['functions'] == ['bar']
        assert context['all_functions'] == ['_quux', 'bar']
>       assert context['classes'] == ['Class', 'Foo']
E       AssertionError: assert ['Class', 'Foo', 'Union'] == ['Class', 'Foo']
E         
E         Left contains one more item: 'Union'
E         Use -v to get more diff

____________________________ test_stringify_Unpack _____________________________

    def test_stringify_Unpack():
        from typing_extensions import Unpack as UnpackCompat
    
        class X(t.TypedDict):
            x: int
            y: int
            label: str
    
        if sys.version_info[:2] >= (3, 11):
            # typing.Unpack is introduced in 3.11 but typing_extensions.Unpack only
            # uses typing.Unpack in 3.12+, so the objects are not synchronised with
            # each other, but we will assume that users use typing.Unpack.
            import typing
    
            UnpackCompat = typing.Unpack  # NoQA: F811
>           assert stringify_annotation(UnpackCompat['X']) == 'Unpack[X]'
E           assert "Unpack[ForwardRef('X')]" == 'Unpack[X]'
E             
E             - Unpack[X]
E             + Unpack[ForwardRef('X')]

tests/test_util/test_util_typing.py:694: AssertionError
_______________________ test_stringify_type_hints_string _______________________

    def test_stringify_type_hints_string():
        assert stringify_annotation('int', 'fully-qualified-except-typing') == 'int'
        assert stringify_annotation('int', 'fully-qualified') == 'int'
        assert stringify_annotation('int', 'smart') == 'int'
    
        assert stringify_annotation('str', 'fully-qualified-except-typing') == 'str'
        assert stringify_annotation('str', 'fully-qualified') == 'str'
        assert stringify_annotation('str', 'smart') == 'str'
    
        ann_str = stringify_annotation(List['int'], 'fully-qualified-except-typing')
>       assert ann_str == 'List[int]'
E       assert "List[ForwardRef('int')]" == 'List[int]'
E         
E         - List[int]
E         + List[ForwardRef('int')]

tests/test_util/test_util_typing.py:716: AssertionError
________________________ test_stringify_type_ForwardRef ________________________

    def test_stringify_type_ForwardRef():
>       assert stringify_annotation(ForwardRef('MyInt')) == 'MyInt'
E       assert "ForwardRef('MyInt')" == 'MyInt'
E         
E         - MyInt
E         + ForwardRef('MyInt')

https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08783529-python-sphinx/

For all our attempts to build python-sphinx with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-sphinx/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Karolina Surma 2025-03-26 13:32:40 UTC
Sphinx 8.2.3 has the issue with the changes in Union in a6:

________ test_autosummary_generate_content_for_module_imported_members _________

app = <SphinxTestApp buildername='html'>

    @pytest.mark.sphinx('html', testroot='ext-autosummary', copy_test_root=True)
    def test_autosummary_generate_content_for_module_imported_members(app):
        import autosummary_dummy_module
    
        template = Mock()
    
        generate_autosummary_content(
            'autosummary_dummy_module',
            autosummary_dummy_module,
            None,
            template,
            None,
            True,
            False,
            {},
            config=app.config,
            events=app.events,
            registry=app.registry,
        )
        assert template.render.call_args[0][0] == 'module'
    
        context = template.render.call_args[0][1]
        assert context['members'] == [
            'CONSTANT1',
            'CONSTANT2',
            'Class',
            'Exc',
            'Foo',
            'Union',
            '_Baz',
            '_Exc',
            '__all__',
            '__builtins__',
            '__cached__',
            '__doc__',
            '__file__',
            '__loader__',
            '__name__',
            '__package__',
            '__spec__',
            '_quux',
            'bar',
            'considered_as_imported',
            'non_imported_member',
            'path',
            'quuz',
            'qux',
        ]
        assert context['functions'] == ['bar']
        assert context['all_functions'] == ['_quux', 'bar']
>       assert context['classes'] == ['Class', 'Foo']
E       AssertionError: assert ['Class', 'Foo', 'Union'] == ['Class', 'Foo']
E         
E         Left contains one more item: 'Union'
E         Use -v to get more diff

tests/test_extensions/test_ext_autosummary.py:450: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: html
# srcdir: /tmp/pytest-of-mockbuild/pytest-0/ext-autosummary
# outdir: /tmp/pytest-of-mockbuild/pytest-0/ext-autosummary/_build/html
# status: 
Running Sphinx v8.2.3
loading translations [en]... done
[autosummary] generating autosummary for: generated/autosummary_dummy_inherited_module.InheritedAttrClass.rst, generated/autosummary_dummy_inherited_module.InheritedAttrClass.subclassattr.rst, generated/autosummary_dummy_module.Foo.Bar.rst, generated/autosummary_dummy_module.Foo.rst, generated/autosummary_dummy_module.Foo.value.rst, generated/autosummary_dummy_module.bar.rst, generated/autosummary_dummy_module.qux.rst, generated/autosummary_dummy_module.rst, index.rst

# warning: 
WARNING: [autosummary] failed to import autosummary_importfail.
Possible hints:
* SystemExit: 1
* KeyError: 'autosummary_importfail'
* ValueError: not enough values to unpack (expected 2, got 1)

________________________ test_is_invalid_builtin_class _________________________

    def test_is_invalid_builtin_class() -> None:
        # if these tests start failing, it means that the __module__
        # of one of these classes has changed, and _INVALID_BUILTIN_CLASSES
        # in sphinx.util.typing needs to be updated.
        invalid_types = (
            # contextvars
            Context,
            ContextVar,
            Token,
            # ctypes
            ctypes.Array,
            ctypes.Structure,
            ctypes.Union,
            # io
            FileIO,
            BytesIO,
            StringIO,
            BufferedReader,
            BufferedWriter,
            BufferedRWPair,
            BufferedRandom,
            TextIOWrapper,
            # json
            JSONDecoder,
            JSONEncoder,
            # lzma
            LZMACompressor,
            LZMADecompressor,
            # multiprocessing
            Process,
            # pickle
            Pickler,
            Unpickler,
            # struct
            Struct,
            # types
            AsyncGeneratorType,
            BuiltinFunctionType,
            BuiltinMethodType,
            CellType,
            ClassMethodDescriptorType,
            CodeType,
            CoroutineType,
            EllipsisType,
            FrameType,
            FunctionType,
            GeneratorType,
            GetSetDescriptorType,
            LambdaType,
            MappingProxyType,
            MemberDescriptorType,
            MethodDescriptorType,
            MethodType,
            MethodWrapperType,
            ModuleType,
            NoneType,
            NotImplementedType,
            TracebackType,
            WrapperDescriptorType,
            # weakref
            WeakSet,
        )
        if sys.version_info[:2] >= (3, 12):
            invalid_types += (
                # zipfile
                zipfile.Path,
                zipfile.CompleteDirs,
            )
        if sys.version_info[:2] >= (3, 13):
            invalid_types += (
                # pathlib
                Path,
                PosixPath,
                PurePath,
                PurePosixPath,
                PureWindowsPath,
                WindowsPath,
            )
    
        invalid_names = {(cls.__module__, cls.__qualname__) for cls in invalid_types}
        if sys.version_info[:2] < (3, 13):
            invalid_names |= {
                ('pathlib._local', 'Path'),
                ('pathlib._local', 'PosixPath'),
                ('pathlib._local', 'PurePath'),
                ('pathlib._local', 'PurePosixPath'),
                ('pathlib._local', 'PureWindowsPath'),
                ('pathlib._local', 'WindowsPath'),
            }
        if sys.version_info[:2] < (3, 12):
            invalid_names |= {
                ('zipfile._path', 'Path'),
                ('zipfile._path', 'CompleteDirs'),
            }
>       assert _INVALID_BUILTIN_CLASSES.keys() == invalid_names
E       AssertionError: assert dict_keys([('...th', 'Path')]) == {('_contextva...'Union'), ...}
E         
E         Use -v to get more diff

Comment 3 Karolina Surma 2025-03-27 12:46:22 UTC
Backported the commits to https://src.fedoraproject.org/rpms/python-sphinx/pull-request/68

Comment 4 Karolina Surma 2025-04-09 09:31:58 UTC
Fixed in python-sphinx-8.2.3-2.fc43


Note You need to log in before you can comment on or make changes to this bug.