mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Update warning, revert my original warning patch
This commit is contained in:
@@ -165,18 +165,15 @@ class Config:
|
|||||||
confdir)
|
confdir)
|
||||||
namespace = eval_config_file(filename, tags)
|
namespace = eval_config_file(filename, tags)
|
||||||
|
|
||||||
# Note: Old sphinx projects has been configured as "langugae = None" because
|
# Note: Old sphinx projects have been configured as "langugae = None" because
|
||||||
# sphinx-quickstart had generated the configuration by default formerly.
|
# sphinx-quickstart previously generated this by default.
|
||||||
# To keep compatibility, they should be fallback to 'en' for a while
|
# To keep compatibility, they should be fallback to 'en' for a while
|
||||||
# (At least 2 years or more since v5.0 release).
|
# (This conversion should not be removed before 2025-01-01).
|
||||||
if namespace.get("language", ...) is None:
|
if namespace.get("language", ...) is None:
|
||||||
logging.warning(__("Invalid configuration found: 'language = None'. "
|
logger.warning(__("Invalid configuration value found: 'language = None'. "
|
||||||
"Now it takes only a string. Please update your configuration. "
|
"Update your configuration to a valid langauge code. "
|
||||||
"Fallback to 'en' (English)."))
|
"Falling back to 'en' (English)."))
|
||||||
namespace["language"] = "en"
|
namespace["language"] = "en"
|
||||||
warnings.warn("'None' is not a valid value for 'language', coercing to 'en'. "
|
|
||||||
"Update 'conf.py' to a valid language code to silence this "
|
|
||||||
"warning.", RuntimeWarning, stacklevel=4)
|
|
||||||
|
|
||||||
return cls(namespace, overrides or {})
|
return cls(namespace, overrides or {})
|
||||||
|
|
||||||
|
|||||||
@@ -397,21 +397,23 @@ def test_conf_py_language_none(tempdir):
|
|||||||
assert cfg.language == "en"
|
assert cfg.language == "en"
|
||||||
|
|
||||||
|
|
||||||
def test_conf_py_language_none_warning(tempdir):
|
def test_conf_py_language_none_warning(tempdir, caplog):
|
||||||
"""Regression test for #10474."""
|
"""Regression test for #10474."""
|
||||||
|
|
||||||
# Given a conf.py file with language = None
|
# Given a conf.py file with language = None
|
||||||
(tempdir / 'conf.py').write_text("language = None", encoding='utf-8')
|
(tempdir / 'conf.py').write_text("language = None", encoding='utf-8')
|
||||||
|
|
||||||
# Then a warning is raised
|
|
||||||
with pytest.warns(
|
|
||||||
RuntimeWarning,
|
|
||||||
match="'None' is not a valid value for 'language', coercing to 'en'. "
|
|
||||||
"Update 'conf.py' to a valid language code to silence this "
|
|
||||||
"warning."):
|
|
||||||
# When we load conf.py into a Config object
|
# When we load conf.py into a Config object
|
||||||
Config.read(tempdir, {}, None)
|
Config.read(tempdir, {}, None)
|
||||||
|
|
||||||
|
# Then a warning is raised
|
||||||
|
assert len(caplog.messages) == 1
|
||||||
|
assert caplog.messages[0] == (
|
||||||
|
"Invalid configuration value found: 'language = None'. "
|
||||||
|
"Update your configuration to a valid langauge code. "
|
||||||
|
"Falling back to 'en' (English).")
|
||||||
|
assert caplog.records[0].levelname == "WARNING"
|
||||||
|
|
||||||
|
|
||||||
def test_conf_py_no_language(tempdir):
|
def test_conf_py_no_language(tempdir):
|
||||||
"""Regression test for #10474."""
|
"""Regression test for #10474."""
|
||||||
|
|||||||
Reference in New Issue
Block a user