From e1788a9d056000f7c289feaca0a629548367f1e8 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 25 Apr 2026 06:55:21 -0700 Subject: [PATCH 1/5] Switched from LOGGER.warn to LOGGER.warning --- tests/test_shortcodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_shortcodes.py b/tests/test_shortcodes.py index 90409ad6f..c0ab88bc2 100644 --- a/tests/test_shortcodes.py +++ b/tests/test_shortcodes.py @@ -183,7 +183,7 @@ def __init__(self): def register_shortcode(self, name, f): """Register function f to handle shortcode "name".""" if name in self.shortcode_registry: - nikola.utils.LOGGER.warn("Shortcode name conflict: %s", name) + nikola.utils.LOGGER.warning("Shortcode name conflict: %s", name) return self.shortcode_registry[name] = f From 597735cf50f54da1f66ece0d8a32062c323f2946 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 25 Apr 2026 18:44:18 -0700 Subject: [PATCH 2/5] update to newer docutils --- nikola/plugins/compile/rest/__init__.py | 6 ++++-- nikola/plugins/compile/rest/listing.py | 4 ++-- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py index 31d01cd8c..0b8e1dcf8 100644 --- a/nikola/plugins/compile/rest/__init__.py +++ b/nikola/plugins/compile/rest/__init__.py @@ -371,10 +371,12 @@ def rst2html(source, source_path=None, source_class=docutils.io.StringInput, 'add_ln': l_add_ln }) - pub = docutils.core.Publisher(reader, parser, writer, settings=settings, + pub = docutils.core.Publisher(reader, + parser=parser or parser_name, + writer=writer or writer_name, + settings=settings, source_class=source_class, destination_class=docutils.io.StringOutput) - pub.set_components(None, parser_name, writer_name) pub.process_programmatic_settings( settings_spec, settings_overrides, config_section) pub.set_source(source, None) diff --git a/nikola/plugins/compile/rest/listing.py b/nikola/plugins/compile/rest/listing.py index f358f281f..1af453851 100644 --- a/nikola/plugins/compile/rest/listing.py +++ b/nikola/plugins/compile/rest/listing.py @@ -40,7 +40,7 @@ from docutils import core from docutils import nodes from docutils.parsers.rst import Directive, directives -from docutils.parsers.rst.roles import set_classes +from docutils.parsers.rst.roles import normalize_options from docutils.parsers.rst.directives.misc import Include from pygments.lexers import get_lexer_by_name @@ -74,7 +74,7 @@ def run(self): language = self.arguments[0] else: language = 'text' - set_classes(self.options) + normalize_options(self.options) classes = ['code'] if language: classes.append(language) diff --git a/pyproject.toml b/pyproject.toml index 5efc2cd96..209bcaf86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ "Pygments>=2.4.2", "Pillow>=9.1.0", "python-dateutil>=2.8.2", - "docutils>=0.19", + "docutils>=0.22", "mako>=1.0.9", "Markdown>=3.0", "unidecode>=0.4.16", From 629a6583aa12ce23b11c933a2336fcff1fb65e7b Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 25 Apr 2026 18:46:12 -0700 Subject: [PATCH 3/5] fix xpath in tests --- tests/integration/test_translated_content.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_translated_content.py b/tests/integration/test_translated_content.py index 9d1338f96..07fc5b17b 100644 --- a/tests/integration/test_translated_content.py +++ b/tests/integration/test_translated_content.py @@ -36,11 +36,11 @@ def test_translated_titles(build, output_dir, other_locale): # And now let's check the titles with io.open(normal_file, "r", encoding="utf8") as inf: doc = lxml.html.parse(inf) - assert doc.find("//title").text == "Foo | Demo Site" + assert doc.find(".//title").text == "Foo | Demo Site" with io.open(translated_file, "r", encoding="utf8") as inf: doc = lxml.html.parse(inf) - assert doc.find("//title").text == "Bar | Demo Site" + assert doc.find(".//title").text == "Bar | Demo Site" @pytest.fixture(scope="module") From 824cc6b0c79c117ddf03b1f688fd0ee287631215 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 25 Apr 2026 18:52:12 -0700 Subject: [PATCH 4/5] replace utcnow (deprecated) with newer function --- nikola/nikola.py | 3 ++- nikola/plugins/command/deploy.py | 4 ++-- nikola/plugins/task/galleries.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nikola/nikola.py b/nikola/nikola.py index 38dda09f9..5743255e8 100644 --- a/nikola/nikola.py +++ b/nikola/nikola.py @@ -27,6 +27,7 @@ """The main Nikola site object.""" import datetime +from datetime import timezone import io import json import functools @@ -1777,7 +1778,7 @@ def generic_rss_feed(self, lang, title, link, description, timeline, title=title, link=utils.encodelink(link), description=description, - lastBuildDate=datetime.datetime.utcnow(), + lastBuildDate=datetime.datetime.now(timezone.utc).replace(tzinfo=None), generator='Nikola (getnikola.com)', language=lang ) diff --git a/nikola/plugins/command/deploy.py b/nikola/plugins/command/deploy.py index 9a47437d2..24b81e91a 100644 --- a/nikola/plugins/command/deploy.py +++ b/nikola/plugins/command/deploy.py @@ -28,7 +28,7 @@ import subprocess import time -from datetime import datetime +from datetime import datetime, timezone import dateutil from blinker import signal @@ -97,7 +97,7 @@ def _execute(self, command, args): self.logger.info("Successful deployment") - new_deploy = datetime.utcnow() + new_deploy = datetime.now(timezone.utc).replace(tzinfo=None) if last_deploy is None: last_deploy = new_deploy self._emit_deploy_event(last_deploy, new_deploy, clean, undeployed_posts) diff --git a/nikola/plugins/task/galleries.py b/nikola/plugins/task/galleries.py index bb4a45851..d01fd43f6 100644 --- a/nikola/plugins/task/galleries.py +++ b/nikola/plugins/task/galleries.py @@ -27,6 +27,7 @@ """Render image galleries.""" import datetime +from datetime import timezone import glob import io import json @@ -763,7 +764,7 @@ def forward_slashes(path): title=title, link=make_url(permalink), description='', - lastBuildDate=datetime.datetime.utcnow(), + lastBuildDate=datetime.datetime.now(timezone.utc).replace(tzinfo=None), items=items, generator='https://getnikola.com/', language=lang From b8bbe7c9d2a1c01e8ae6fecdd8ea3cc558a941ef Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sun, 26 Apr 2026 06:56:49 -0700 Subject: [PATCH 5/5] docutils: revert to also be able to use older version, but still fix the deprecated warning using normalize_options when available --- nikola/plugins/compile/rest/__init__.py | 6 ++---- nikola/plugins/compile/rest/listing.py | 8 +++++++- pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py index 0b8e1dcf8..31d01cd8c 100644 --- a/nikola/plugins/compile/rest/__init__.py +++ b/nikola/plugins/compile/rest/__init__.py @@ -371,12 +371,10 @@ def rst2html(source, source_path=None, source_class=docutils.io.StringInput, 'add_ln': l_add_ln }) - pub = docutils.core.Publisher(reader, - parser=parser or parser_name, - writer=writer or writer_name, - settings=settings, + pub = docutils.core.Publisher(reader, parser, writer, settings=settings, source_class=source_class, destination_class=docutils.io.StringOutput) + pub.set_components(None, parser_name, writer_name) pub.process_programmatic_settings( settings_spec, settings_overrides, config_section) pub.set_source(source, None) diff --git a/nikola/plugins/compile/rest/listing.py b/nikola/plugins/compile/rest/listing.py index 1af453851..7e996d468 100644 --- a/nikola/plugins/compile/rest/listing.py +++ b/nikola/plugins/compile/rest/listing.py @@ -37,13 +37,19 @@ import docutils.parsers.rst.directives.misc import pygments import pygments.util +import docutils from docutils import core from docutils import nodes from docutils.parsers.rst import Directive, directives -from docutils.parsers.rst.roles import normalize_options from docutils.parsers.rst.directives.misc import Include from pygments.lexers import get_lexer_by_name +# Compatibility layer for docutils versions +if docutils.__version_info__[:2] >= (0, 22): + from docutils.parsers.rst.roles import normalize_options +else: + from docutils.parsers.rst.roles import set_classes as normalize_options + from nikola import utils from nikola.plugin_categories import RestExtension diff --git a/pyproject.toml b/pyproject.toml index 209bcaf86..5efc2cd96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ "Pygments>=2.4.2", "Pillow>=9.1.0", "python-dateutil>=2.8.2", - "docutils>=0.22", + "docutils>=0.19", "mako>=1.0.9", "Markdown>=3.0", "unidecode>=0.4.16",