You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using markupsafe within a jinja2 environment, and ran into an issue not present in 2.1.5, but occurs in 3.0.0 and 3.0.1, running on python 3.12.6 and python 3.12.7:
Traceback (most recent call last):
File "markupsafe_error.py", line 9, in <module>
result = env.from_string('{{ value }}').render({'value': Something()})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/jinja2/environment.py", line 1304, in render
self.environment.handle_exception()
File "lib/python3.12/site-packages/jinja2/environment.py", line 939, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "lib/python3.12/site-packages/markupsafe/__init__.py", line 45, in escape
return Markup(_escape_inner(str(s)))
^^^^^^^^^^^^^^^^^^^^^
SystemError: <built-in function _escape_inner> returned NULL without setting an exception
It occurs when attempting to evaluate the result of escape in a jinja template coming from the __str__ of an object, when the jinja environment has autoescape set to True. I realize this is redundant (having autoescape + using escape), but this is in an older code base where tracking down all redundant uses is not ideal and does look to be a regression from 2.1.5 which does not produce an error.
fromjinja2importEnvironmentfrommarkupsafeimportescapeclassSomething:
def__str__(self):
returnescape('something')
env=Environment(autoescape=True)
env.from_string('{{ value }}').render({'value': Something()})
Environment:
Python version: 3.12.6 and 3.12.7
MarkupSafe version: 3.0.0 and 3.0.1
I'm guessing one of the recent refactorings to the c code may have introduced this regression: #434 #437
The text was updated successfully, but these errors were encountered:
We are using markupsafe within a jinja2 environment, and ran into an issue not present in 2.1.5, but occurs in 3.0.0 and 3.0.1, running on python 3.12.6 and python 3.12.7:
It occurs when attempting to evaluate the result of
escape
in a jinja template coming from the__str__
of an object, when the jinja environment has autoescape set toTrue
. I realize this is redundant (having autoescape + using escape), but this is in an older code base where tracking down all redundant uses is not ideal and does look to be a regression from 2.1.5 which does not produce an error.Environment:
I'm guessing one of the recent refactorings to the c code may have introduced this regression:
#434
#437
The text was updated successfully, but these errors were encountered: