#13404 closed defect (fixed)
ImportError: cannot import name 'soft_unicode' from 'jinja2.utils' with Jinja2 3.0.x — at Version 4
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.5.4 |
Component: | rendering | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Make compatible with Jinja 3 and add workaround for |
||
API Changes: | |||
Internal Changes: |
Description
====================================================================== ERROR: test (unittest.loader._FailedTest) ---------------------------------------------------------------------- ImportError: Failed to import test module: test Traceback (most recent call last): File "/opt/python/3.9.1/lib/python3.9/unittest/loader.py", line 154, in loadTestsFromName module = __import__(module_name) File "/home/travis/build/edgewall/trac/trac/test.py", line 47, in <module> from trac.env import Environment File "/home/travis/build/edgewall/trac/trac/env.py", line 52, in <module> from trac.web.chrome import Chrome File "/home/travis/build/edgewall/trac/trac/web/chrome.py", line 40, in <module> from trac.mimeview.api import RenderingContext, get_mimetype File "/home/travis/build/edgewall/trac/trac/mimeview/__init__.py", line 14, in <module> from trac.mimeview.api import * File "/home/travis/build/edgewall/trac/trac/mimeview/api.py", line 70, in <module> from trac.resource import Resource File "/home/travis/build/edgewall/trac/trac/resource.py", line 21, in <module> from trac.util.presentation import classes File "/home/travis/build/edgewall/trac/trac/util/presentation.py", line 26, in <module> from jinja2.utils import soft_unicode ImportError: cannot import name 'soft_unicode' from 'jinja2.utils' (/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/jinja2/utils.py)
Jinja2 2.11.3 says the following warning when calling soft_unicode()
but no warnings when importing it.
$ ~/venv/py39/bin/python Python 3.9.4 (default, Apr 9 2021, 01:15:05) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import jinja2 >>> jinja2.__version__ '2.11.3' >>> from jinja2.utils import soft_unicode >>> soft_unicode('***') <stdin>:1: DeprecationWarning: 'jinja2.utils.soft_unicode' will be removed in version 3.0. Use 'markupsafe.soft_unicode' instead. '***'
Change History (4)
comment:1 by , 3 years ago
comment:2 by , 3 years ago
The AssertionError: Tried to resolve a name ...
has been filed at https://github.com/pallets/jinja/issues/1427 and a workaround has been posted in the page.
Proposed changes in jomae.git@t13404, tested with Jinja 3.0.0 and 2.11.3.
comment:3 by , 3 years ago
Changes look good. Do you think we should create another release soon since this upgrading Jinja2 will cause breakage in production?
comment:4 by , 3 years ago
Component: | general → rendering |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | assigned → closed |
Thanks for the reviewing. Committed in [17543].
Hmm, I don't think new release is not necessary for this issue. We don't recommend to use 1.5.x releasees in production because it is for development. It is easy to downgrade to Jinja2<3
for 1.5.x users.
2 deprecated warnings are raised while running unit-test with Jinja2 3.0.0:
Also, 2 failures.