Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jinja2.Markup() fails without deprecation warning #1438

encukou opened this issue May 17, 2021 · 1 comment · Fixed by #1439

jinja2.Markup() fails without deprecation warning #1438

encukou opened this issue May 17, 2021 · 1 comment · Fixed by #1439


Copy link

encukou commented May 17, 2021

There might not be anything to do now, but the code that issues a DeprecationWarning since 3.0.0rc2 fails with an exception when jinja2.utils.Markup is used without arguments. The previous RC worked.

>>> import jinja2
>>> jinja2.Markup()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __new__() missing 1 required positional argument: 'base'

The correct fix is to switch to markupsafe, but the exception makes it hard to find if an application uses Markup() first.

>>> import markupsafe
>>> markupsafe.Markup()

While looking for the cause, I found that documentation for the autoescape argument for jinja2.Environment mentions Markup without much context; is that an issue?


  • Python version: 3.11.0a0
  • Jinja version: 3.0.0
@encukou encukou changed the title jinja2.Markup() fails without deprecation jinja2.Markup() fails without deprecation warning May 17, 2021
Copy link

Ah, I messed up and didn't give base a default value of "".

@davidism davidism added this to the 3.0.1 milestone May 17, 2021
@davidism davidism self-assigned this May 17, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

Successfully merging a pull request may close this issue.

2 participants