Skip to content

Docs fail to build on Python 3.14 (ast.Constant.s no longer supported) #429

Description

@TTsangSC

docs/source/conf.py::parse_version() fails on Python 3.14 because ast.Constant nodes no longer provides the backward-compatible .s field:

Sample output
(py3.14)  $ make html
Running Sphinx v9.1.0

Configuration error!

Versions
========

* Platform:         darwin; (macOS-15.6.1-arm64-arm-64bit-Mach-O)
* Python version:   3.14.0 (CPython)
* Sphinx version:   9.1.0
* Docutils version: 0.22.4
* Jinja2 version:   3.1.6
* Pygments version: 2.19.2

Last Messages
=============

None.

Loaded Extensions
=================

None.

Traceback
=========

      File "[...]/py3.14/lib/python3.14/site-packages/sphinx/config.py", line 611, in eval_config_file
        raise ConfigError(msg % traceback.format_exc()) from exc
    sphinx.errors.ConfigError: There is a programmable error in your configuration file:
    
    Traceback (most recent call last):
      File "[...]/py3.14/lib/python3.14/site-packages/sphinx/config.py", line 596, in eval_config_file
        exec(code, namespace)  # NoQA: S102
        ~~~~^^^^^^^^^^^^^^^^^
      File "[...]/line_profiler/docs/source/conf.py", line 152, in <module>
        release = parse_version(modpath)
      File "[...]/line_profiler/docs/source/conf.py", line 139, in parse_version
        visitor.visit(pt)
        ~~~~~~~~~~~~~^^^^
      File "/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File "/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/ast.py", line 514, in generic_visit
        self.visit(item)
        ~~~~~~~~~~^^^^^^
      File "/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File "[...]/line_profiler/docs/source/conf.py", line 136, in visit_Assign
        self.version = node.value.s
                       ^^^^^^^^^^^^
    AttributeError: 'Constant' object has no attribute 's'


The full traceback has been saved in:
/var/folders/5b/44kj9cdn7gngz2k1z1wxt0240000gp/T/sphinx-err-80c1sauj.log

To report this error to the developers, please open an issue at <https://github.com/sphinx-doc/sphinx/issues/>. Thanks!
Please also report this if it was a user error, so that a better error message can be provided next time.
make: *** [html] Error 2

Since we're dropping 3.8 support anyway – and even 3.8 uses ast.Constant instead of the earlier specialized ast.Str, ast.Num, etc. – I guess we can just update to .value.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions