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/compile/rest/listing.py b/nikola/plugins/compile/rest/listing.py index f358f281f..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 set_classes 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 @@ -74,7 +80,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/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 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") 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