Skip to content

Deprecation warning 'invalid escape sequence \s' raised in Python 3.10 #3695

@lyz-code

Description

@lyz-code

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

When building the site with the material theme jinja2 complains with a DeprecationWarning

Expected behaviour

No DeprecationWarning is raised

Actual behaviour

DeprecationWarning: invalid escape sequence '\s'

The above exception was the direct cause of the following exception:
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/jinja2/lexer.py:652: in wrap
    self._normalize_newlines(value_str[1:-1])
E   DeprecationWarning: decoding with 'unicode-escape' codec failed (DeprecationWarning: invalid escape sequence '\s')

The above exception was the direct cause of the following exception:
tests/e2e/test_plugin.py:123: in test_plugin_creates_weekly_rss_feed
    build.build(config)  # act
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/mkdocs/commands/build.py:306: in build
    _build_theme_template(template, env, files, config, nav)
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/mkdocs/commands/build.py:111: in _build_theme_template
    output = _build_template(template_name, template, files, config, nav)
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/mkdocs/commands/build.py:90: in _build_template
    output = template.render(context)
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/jinja2/environment.py:1291: in render
    self.environment.handle_exception()
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/jinja2/environment.py:925: in handle_exception
    raise rewrite_traceback_stack(source=source)
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/material/404.html:4: in top-level template code
    {% extends "main.html" %}
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/material/main.html:4: in top-level template code
    {% extends "base.html" %}
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/material/base.html:4: in top-level template code
    {% import "partials/language.html" as lang with context %}
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/jinja2/environment.py:1399: in make_module
    return TemplateModule(self, ctx)
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/jinja2/environment.py:1529: in __init__
    body_stream = list(template.root_render_func(context))  # type: ignore
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/material/partials/language.html:4: in top-level template code
    {% import "partials/languages/" ~ config.theme.language ~ ".html" as lang %}
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/jinja2/environment.py:925: in handle_exception
    raise rewrite_traceback_stack(source=source)
../../.venvs/mkdocs-newsletter/lib/python3.9/site-packages/material/partials/languages/en.html:19: in template
    "search.config.separator": "[\s\-]+",
E   jinja2.exceptions.TemplateSyntaxError: invalid escape sequence '\s')

Steps to reproduce

  1. Build the site programmatically with warnings set.

Package versions

  • Python: Python 3.9.10
  • MkDocs: mkdocs, version 1.2.3 from ../mkdocs-newsletter/lib/python3.9/site-packages/mkdocs (Python 3.9)
  • Material: Version: 8.2.5

Configuration

---
site_name: The Blue Book
site_description: My second brain
site_author: Lyz
site_url: https://lyz-code.github.io/blue-book
site_dir: site
nav:
  - Introduction: index.md

plugins:
  - git-revision-date-localized:
      type: timeago
  - autolinks
  - section-index
  - mkdocs-newsletter

markdown_extensions:
  - toc:
      baselevel: 2
theme:
  name: material
  logo: img/logo.bmp

System information

  • Operating system: Debian
  • Browser: Irrelevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions