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
When executed under Python 3.10, the testsuite fails with
=================================== FAILURES ===================================
_________________________ TestDebug.test_runtime_error _________________________
self = <test_debug.TestDebug object at 0x7fbdec31d4f0>
fs_env = <jinja2.environment.Environment object at 0x7fbdec31d4c0>
def test_runtime_error(self, fs_env):
def test():
tmpl.render(fail=lambda: 1 / 0)
tmpl = fs_env.get_template("broken.html")
> self.assert_traceback_matches(
test,
r"""
File ".*?broken.html", line 2, in (top-level template code|<module>)
\{\{ fail\(\) \}\}
File ".*debug?.pyc?", line \d+, in <lambda>
tmpl\.render\(fail=lambda: 1 / 0\)
ZeroDivisionError: (int(eger)? )?division (or modulo )?by zero
""",
)
tests/test_debug.py:37:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <test_debug.TestDebug object at 0x7fbdec31d4f0>
callback = <function TestDebug.test_runtime_error.<locals>.test at 0x7fbdec30b3a0>
expected_tb = '\n File ".*?broken.html", line 2, in (top-level template code|<module>)\n \\{\\{ fail\\(\\) \\}\\}\n File ".*deb... <lambda>\n tmpl\\.render\\(fail=lambda: 1 / 0\\)\nZeroDivisionError: (int(eger)? )?division (or modulo )?by zero\n'
def assert_traceback_matches(self, callback, expected_tb):
with pytest.raises(Exception) as exc_info:
callback()
tb = format_exception(exc_info.type, exc_info.value, exc_info.tb)
m = re.search(expected_tb.strip(), "".join(tb))
> assert m is not None, "Traceback did not match:\n\n%s\nexpected:\n%s" % (
"".join(tb),
expected_tb,
)
E AssertionError: Traceback did not match:
E
E Traceback (most recent call last):
E File "/builddir/build/BUILD/Jinja2-2.11.2/tests/test_debug.py", line 23, in assert_traceback_matches
E callback()
E File "/builddir/build/BUILD/Jinja2-2.11.2/tests/test_debug.py", line 34, in test
E tmpl.render(fail=lambda: 1 / 0)
E File "/builddir/build/BUILD/Jinja2-2.11.2/src/jinja2/asyncsupport.py", line 71, in render
E return original_render(self, *args, **kwargs)
E File "/builddir/build/BUILD/Jinja2-2.11.2/src/jinja2/environment.py", line 1090, in render
E self.environment.handle_exception()
E File "/builddir/build/BUILD/Jinja2-2.11.2/src/jinja2/environment.py", line 832, in handle_exception
E reraise(*rewrite_traceback_stack(source=source))
E File "/builddir/build/BUILD/Jinja2-2.11.2/src/jinja2/_compat.py", line 28, in reraise
E raise value.with_traceback(tb)
E File "/builddir/build/BUILD/Jinja2-2.11.2/tests/res/templates/broken.html", line -62, in top-level template code
E File "/builddir/build/BUILD/Jinja2-2.11.2/tests/test_debug.py", line 34, in <lambda>
E tmpl.render(fail=lambda: 1 / 0)
E ZeroDivisionError: division by zero
E
E expected:
E
E File ".*?broken.html", line 2, in (top-level template code|<module>)
E \{\{ fail\(\) \}\}
E File ".*debug?.pyc?", line \d+, in <lambda>
E tmpl\.render\(fail=lambda: 1 / 0\)
E ZeroDivisionError: (int(eger)? )?division (or modulo )?by zero
E
E assert None is not None
tests/test_debug.py:27: AssertionError
As part of python/cpython#23113 partly
implementing PEP 626 (see https://bugs.python.org/issue42246), the
co_lnotab member of struct PyCodeObject was replaced by co_linetable,
implementing a new line number table.
This commit therefore adds linetable to the list of attributes that
are copied over into the final CodeType executed by fake_traceback()
to ensure proper line numbers and contents in fake stack traces
generated when running under Python 3.10.
Fixespallets#1333.
When executed under Python 3.10, the testsuite fails with
See https://bugzilla.redhat.com/show_bug.cgi?id=1907442
Environment:
The text was updated successfully, but these errors were encountered: