pallets / jinja

A very fast and expressive template engine.

Home Page:https://jinja.palletsprojects.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test failures with Python 3.13.0a1

hroncok opened this issue · comments

Hello,
in Fedora, we are trying to test Python 3.13 early to discover problems in Python itself and in important packages in the Python ecosystem.

With 3.13.0a1, we see some of the jinja's tests failing. I haven't got into investigating the failures just yet, but I decided to open this issue here. I understand that jinja is not expected to work on a first alpha release of Python out of the box, but I assume you are interested in knowing this.

  • 5 tests fail with pytest.PytestUnraisableExceptionWarning
  • 1 fails with TypeError: This zip import does not have the required metadata to list templates.

To reproduce, clone this repository and run tox -e py313.

(I used tox 3, so I needed to add isolated_build = True to the tox config. I assume this is not needed with tox 4.)

py313 inst-nodeps: .../jinja/.tox/.tmp/package/1/jinja2-3.2.0.dev0.tar.gz
py313 installed: exceptiongroup==1.1.1,iniconfig==2.0.0,Jinja2 @ file://.../jinja/.tox/.tmp/package/1/jinja2-3.2.0.dev0.tar.gz#sha256=42294b609cdaac372cdea7a710ae77f5491892dc6031d78ddbd5d01ac121f08c,MarkupSafe==2.1.3,packaging==23.1,pluggy==1.2.0,pytest==7.4.0,tomli==2.0.1
py313 run-test-pre: PYTHONHASHSEED='3531310174'
py313 run-test: commands[0] | pytest -v --tb=short --basetemp=.../jinja/.tox/py313/tmp
============================= test session starts ==============================
platform linux -- Python 3.13.0a1, pytest-7.4.0, pluggy-1.2.0 -- .../jinja/.tox/py313/bin/python
cachedir: .tox/py313/.pytest_cache
rootdir: .../jinja
configfile: pyproject.toml
testpaths: tests
collecting ... collected 842 items

...
tests/test_async.py::TestAsyncForLoop::test_loop_errors FAILED           [  8%]
...
tests/test_async_filters.py::test_first[<lambda>0] FAILED                [ 10%]
tests/test_async_filters.py::test_first[<lambda>1] FAILED                [ 11%]
...
tests/test_async_filters.py::test_custom_async_iteratable_filter[<lambda>0] FAILED [ 15%]
tests/test_async_filters.py::test_custom_async_iteratable_filter[<lambda>1] FAILED [ 15%]
...
tests/test_loader.py::test_package_zip_list FAILED                       [ 72%]
...
=================================== FAILURES ===================================
______________________ TestAsyncForLoop.test_loop_errors _______________________
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
.tox/py313/lib/python3.13/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:78: in unraisable_exception_runtest_hook
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object auto_aiter at 0x7f736e73a5a0>
E   
E   Traceback (most recent call last):
E     File ".../jinja/.tox/py313/lib/python3.13/site-packages/_pytest/python_api.py", line 951, in raises
E       func(*args[1:], **kwargs)
E     File ".../jinja/.tox/py313/lib/python3.13/site-packages/jinja2/environment.py", line 1293, in render
E       return loop.run_until_complete(self.render_async(*args, **kwargs))
E              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E     File "/usr/lib64/python3.13/asyncio/base_events.py", line 664, in run_until_complete
E       return future.result()
E              ^^^^^^^^^^^^^^^
E     File ".../jinja/.tox/py313/lib/python3.13/site-packages/jinja2/environment.py", line 1326, in render_async
E       return self.environment.handle_exception()
E              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E     File ".../jinja/.tox/py313/lib/python3.13/site-packages/jinja2/environment.py", line 938, in handle_exception
E       raise rewrite_traceback_stack(source=source)
E     File "<template>", line 1, in top-level template code
E     File "<template>", line 2, in template
E     File ".../jinja/.tox/py313/lib/python3.13/site-packages/jinja2/environment.py", line 487, in getattr
E       return getattr(obj, attribute)
E              ^^^^^^^^^^^^^^^^^^^^^^^
E   jinja2.exceptions.UndefinedError: 'loop' is undefined
E   
E   During handling of the above exception, another exception occurred:
E   
E   Traceback (most recent call last):
E     File "/usr/lib64/python3.13/asyncio/base_events.py", line 689, in close
E       self._ready.clear()
E   RuntimeWarning: coroutine method 'aclose' of 'auto_aiter' was never awaited
------------------------------ Captured log call -------------------------------
ERROR    asyncio:base_events.py:1785 Task was destroyed but it is pending!
task: <Task pending name='Task-81' coro=<<async_generator_athrow without __name__>()>>
____________________________ test_first[<lambda>0] _____________________________
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
.tox/py313/lib/python3.13/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:78: in unraisable_exception_runtest_hook
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object auto_aiter at 0x7f736f24edc0>
E   
E   Traceback (most recent call last):
E     File "/usr/lib64/python3.13/asyncio/base_events.py", line 689, in close
E       self._ready.clear()
E   RuntimeWarning: coroutine method 'aclose' of 'auto_aiter' was never awaited
------------------------------ Captured log call -------------------------------
ERROR    asyncio:base_events.py:1785 Task was destroyed but it is pending!
task: <Task pending name='Task-111' coro=<<async_generator_athrow without __name__>()>>
____________________________ test_first[<lambda>1] _____________________________
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
.tox/py313/lib/python3.13/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:78: in unraisable_exception_runtest_hook
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object auto_aiter at 0x7f736e04cc70>
E   
E   Traceback (most recent call last):
E     File "/usr/lib64/python3.13/asyncio/base_events.py", line 689, in close
E       self._ready.clear()
E   RuntimeWarning: coroutine method 'aclose' of 'auto_aiter' was never awaited
------------------------------ Captured log call -------------------------------
ERROR    asyncio:base_events.py:1785 Task was destroyed but it is pending!
task: <Task pending name='Task-113' coro=<<async_generator_athrow without __name__>()>>
________________ test_custom_async_iteratable_filter[<lambda>0] ________________
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
.tox/py313/lib/python3.13/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:78: in unraisable_exception_runtest_hook
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object auto_aiter at 0x7f736e04ca00>
E   
E   Traceback (most recent call last):
E     File "/usr/lib64/python3.13/asyncio/base_events.py", line 689, in close
E       self._ready.clear()
E   RuntimeWarning: coroutine method 'aclose' of 'auto_aiter' was never awaited
------------------------------ Captured log call -------------------------------
ERROR    asyncio:base_events.py:1785 Task was destroyed but it is pending!
task: <Task pending name='Task-154' coro=<<async_generator_athrow without __name__>()>>
ERROR    asyncio:base_events.py:1785 Task was destroyed but it is pending!
task: <Task pending name='Task-155' coro=<<async_generator_athrow without __name__>()>>
________________ test_custom_async_iteratable_filter[<lambda>1] ________________
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
.tox/py313/lib/python3.13/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
.tox/py313/lib/python3.13/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:78: in unraisable_exception_runtest_hook
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object auto_aiter at 0x7f736e25a8e0>
E   
E   Traceback (most recent call last):
E     File "/usr/lib64/python3.13/asyncio/base_events.py", line 689, in close
E       self._ready.clear()
E   RuntimeWarning: coroutine method 'aclose' of 'auto_aiter' was never awaited
------------------------------ Captured log call -------------------------------
ERROR    asyncio:base_events.py:1785 Task was destroyed but it is pending!
task: <Task pending name='Task-157' coro=<<async_generator_athrow without __name__>()>>
ERROR    asyncio:base_events.py:1785 Task was destroyed but it is pending!
task: <Task pending name='Task-158' coro=<<async_generator_athrow without __name__>()>>
____________________________ test_package_zip_list _____________________________
tests/test_loader.py:372: in test_package_zip_list
    assert package_zip_loader.list_templates() == ["foo/test.html", "test.html"]
.tox/py313/lib/python3.13/site-packages/jinja2/loaders.py:385: in list_templates
    raise TypeError(
E   TypeError: This zip import does not have the required metadata to list templates.
=========================== short test summary info ============================
FAILED tests/test_async.py::TestAsyncForLoop::test_loop_errors - pytest.Pytes...
FAILED tests/test_async_filters.py::test_first[<lambda>0] - pytest.PytestUnra...
FAILED tests/test_async_filters.py::test_first[<lambda>1] - pytest.PytestUnra...
FAILED tests/test_async_filters.py::test_custom_async_iteratable_filter[<lambda>0]
FAILED tests/test_async_filters.py::test_custom_async_iteratable_filter[<lambda>1]
FAILED tests/test_loader.py::test_package_zip_list - TypeError: This zip impo...
======================== 6 failed, 836 passed in 5.91s =========================
ERROR: InvocationError for command .../jinja/.tox/py313/bin/pytest -v --tb=short --basetemp=.../jinja/.tox/py313/tmp (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py313: commands failed

Environment:

  • Python version: 3.13.0a1
  • Jinja version: d594969

Please report this again once 3.13 beta is released, if it's still an issue.

Huh. You have it right here. Happy to retest with betas, but I don't understand the closure.

There's not really a need to report this. We'll enable 3.13 test env once it's in beta or rc phase, at which point we'll see these failures if they're still happening. You're welcome to report them if you're also planning to submit a fix at the same time, but otherwise it just creates a placeholder that's not useful to us. Alpha is also way too early to start reporting this, as it's not stable yet and so doesn't indicate what we may actually need to fix.