Skip to content

If a project defines "language = None" in conf.py, treat it like "en" #10474

@befeleme

Description

@befeleme

Hello, I started working on integrating Sphinx 5 to Fedora to ensure distribution packages work smoothly when the final is out.
I ran across is a side effect of the change inspired by #10062.
If a project has already "language = None" defined in their conf.py (which, it seems, used to be an issue before this commit), the new behavior will cause the documentation build to error out. The projects created after the mentioned commit seem not to be affected.
In a sample of ~40 packages, 2 have run across this issue.
A naive check using grep.app shows that for a half a million indexed GitHub projects there is around 6k which have the string in their conf.py (I removed the commented strings from the equation).
For older projects using Sphinx, this change will be disruptive and will require the same commit in the same place for each and every one of them.

The exact error:

+ python3 setup.py build_sphinx
running build_sphinx
Running Sphinx v5.0.0b1
loading translations [None]... not available for built-in messages
making output directory... done
WARNING: The config value `language' has type `NoneType'; expected `str'.

Extension error (sphinx.config):
Handler <function check_confval_types at 0x7fd1e67a6c00> for event 'config-inited' threw an exception (exception: 'NoneType' object has no attribute 'startswith')

Describe the solution you'd like
When Sphinx encounters NoneType for language, it could set the language to English and log the fact for the user (possibly asking them to make adjustments to conf.py) instead of erroring.
It's not that different than the current behavior in 5.0.0b1. When if I run sphinx-quickstart and set no language, the variable is not present at all in conf.py, although in the background my project is processed as English.

Describe alternatives you've considered
Aforementioned manual change for each affected project, which I'm afraid of.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions