mako icon indicating copy to clipboard operation
mako copied to clipboard

ExceptionsTest.test_alternating_file_names fails on pypy3

Open mgorny opened this issue 4 years ago • 4 comments

When running mako's tests with pypy3, I get one failure:

==================================================================== FAILURES =====================================================================
___________________________________________________ ExceptionsTest.test_alternating_file_names ____________________________________________________
Traceback (most recent call last):
  File "/tmp/portage/dev-python/mako-1.1.1/work/Mako-1.1.1/test/test_exceptions.py", line 457, in test_alternating_file_names
    t.render()
  File "/tmp/portage/dev-python/mako-1.1.1/work/Mako-1.1.1/mako/template.py", line 476, in render
    return runtime._render(self, self.callable_, args, data)
  File "/tmp/portage/dev-python/mako-1.1.1/work/Mako-1.1.1/mako/runtime.py", line 883, in _render
    **_kwargs_for_callable(callable_, data)
  File "/tmp/portage/dev-python/mako-1.1.1/work/Mako-1.1.1/mako/runtime.py", line 920, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/tmp/portage/dev-python/mako-1.1.1/work/Mako-1.1.1/mako/runtime.py", line 947, in _exec_template
    callable_(context, *args, **kwargs)
  File "base_html", line 30, in render_body
  File "/usr/lib/pypy3.6/lib_pypy/_functools.py", line 80, in __call__
    return self._func(*(self._args + fargs), **fkeywords)
  File "foo_html", line 54, in render_foo
  File "/usr/lib/pypy3.6/lib_pypy/_functools.py", line 80, in __call__
    return self._func(*(self._args + fargs), **fkeywords)
  File "base_html", line 46, in render_foo
  File "base_html", line 17, in broken
RuntimeError: Something went wrong.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/portage/dev-python/mako-1.1.1/work/Mako-1.1.1/test/test_exceptions.py", line 460, in test_alternating_file_names
    assert """
AssertionError: assert '\n  File "base.html", line 5, in render_body\n    %> body starts here\n  File "foo.html", line 4, in render_foo\n    ... render_foo\n    ${broken()}\n  File "base.html", line 4, in broken\n    raise RuntimeError("Something went wrong.")\n' in '\n\nTraceback (most recent call last):\n  File "/tmp/portage/dev-python/mako-1.1.1/work/Mako-1.1.1/test/test_exceptio..."base.html", line 4, in broken\n    raise RuntimeError("Something went wrong.")\nRuntimeError: Something went wrong.\n'
============================================================= short test summary info =============================================================
FAILED test/test_exceptions.py::ExceptionsTest::test_alternating_file_names - AssertionError: assert '\n  File "base.html", line 5, in render_bo...
================================================ 1 failed, 415 passed, 53 skipped in 23.80 seconds ================================================

mgorny avatar Feb 21 '20 17:02 mgorny

FWICS the traceback for PyPy3 is:

Traceback (most recent call last):
  File "/tmp/mako/test/test_exceptions.py", line 457, in test_alternating_file_names
    t.render()
  File "/tmp/mako/mako/template.py", line 476, in render
    return runtime._render(self, self.callable_, args, data)
  File "/tmp/mako/mako/runtime.py", line 883, in _render
    **_kwargs_for_callable(callable_, data)
  File "/tmp/mako/mako/runtime.py", line 920, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/tmp/mako/mako/runtime.py", line 947, in _exec_template
    callable_(context, *args, **kwargs)
  File "base.html", line 5, in render_body
    %> body starts here
  File "/usr/lib/pypy3.6/lib_pypy/_functools.py", line 80, in __call__
    return self._func(*(self._args + fargs), **fkeywords)
  File "foo.html", line 4, in render_foo
    ${parent.foo()}
  File "/usr/lib/pypy3.6/lib_pypy/_functools.py", line 80, in __call__
    return self._func(*(self._args + fargs), **fkeywords)
  File "base.html", line 7, in render_foo
    ${broken()}
  File "base.html", line 4, in broken
    raise RuntimeError("Something went wrong.")
RuntimeError: Something went wrong.

while for CPython 3.6 it is:

Traceback (most recent call last):
  File "/tmp/mako/test/test_exceptions.py", line 457, in test_alternating_file_names
    t.render()
  File "/tmp/mako/mako/template.py", line 476, in render
    return runtime._render(self, self.callable_, args, data)
  File "/tmp/mako/mako/runtime.py", line 883, in _render
    **_kwargs_for_callable(callable_, data)
  File "/tmp/mako/mako/runtime.py", line 920, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/tmp/mako/mako/runtime.py", line 947, in _exec_template
    callable_(context, *args, **kwargs)
  File "base.html", line 5, in render_body
    %> body starts here
  File "foo.html", line 4, in render_foo
    ${parent.foo()}
  File "base.html", line 7, in render_foo
    ${broken()}
  File "base.html", line 4, in broken
    raise RuntimeError("Something went wrong.")
RuntimeError: Something went wrong.

i.e. PyPy3 intersperses the fancy output twice with:

  File "/usr/lib/pypy3.6/lib_pypy/_functools.py", line 80, in __call__
    return self._func(*(self._args + fargs), **fkeywords)

mgorny avatar Feb 21 '20 18:02 mgorny

this is a very old test but it does need to assert some way of seeing that the stack trace is correct. I can accept PRs that attempt to refine its approach of asserting this.

zzzeek avatar Feb 21 '20 18:02 zzzeek

To be honest, I'm not even sure if it isn't a bug in PyPy3. Are you suggesting accepting this output?

mgorny avatar Feb 21 '20 18:02 mgorny

I'm not sure either but it looks like functools is in pure Python in pypy, which makes sense, im not really sure what the Mako templates are doing involving that, I'd assume its functools.partial() and perhaps in cPython this doesn't put itself into stack traces, not really sure. i don't maintain Mako at this level right now.

zzzeek avatar Feb 21 '20 18:02 zzzeek