Edgewall Software

Opened 11 years ago

Last modified 7 years ago

#568 new defect

Missing arguments to called py:def function results in opaque error

Reported by: geordan@… Owned by: cmlenz
Priority: minor Milestone: 0.9
Component: General Version: 0.6
Keywords: py:def nonetype evaluate attributeerror Cc:

Description

The following template code:

        <py:def function="foo(bar)"></py:def>
        ${foo()}

results in a AttributeError?: 'NoneType?' object has no attribute 'evaluate':

Traceback (most recent call last):
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/home/geordan/src/dev/mms/webapp/app.wsgi", line 159, in _app
    return application(environ, start_response)
  File "/home/geordan/src/dev/mms/webapp/app.wsgi", line 92, in application
    return app(environ, start_response)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/geordan/src/dev/mms/webapp/middleware/outdated_browser_intercept.py", line 37, in __call__
    return self._app(environ, start_response)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/werkzeug/contrib/fixers.py", line 157, in __call__
    return self.app(environ, rewriting_start_response)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/repoze/who/middleware.py", line 87, in __call__
    app_iter = app(environ, wrapper.wrap_start_response)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/geordan/src/dev/mms/webapp/middleware/repoze_auth.py", line 164, in _f
    return f(*args, **kwargs)
  File "/home/geordan/src/dev/mms/webapp/check/index.py", line 60, in checkDetails
    return details.checkDetails(model, request_obj)
  File "/home/geordan/src/dev/mms/webapp/check/v1_2_0/details.py", line 84, in checkDetails
    return render_response('check/v1_2_0/main.html', context)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flaskext/genshi.py", line 278, in render_response
    template = render_template(template, context, method, string, filter)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/flaskext/genshi.py", line 266, in render_template
    return template.render(**render_args)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/output.py", line 57, in encode
    return _encode(''.join(list(iterator)))
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/output.py", line 470, in __call__
    for kind, data, _ in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/output.py", line 826, in __call__
    for kind, data, pos in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/output.py", line 670, in __call__
    for kind, data, pos in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/output.py", line 771, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/output.py", line 586, in __call__
    for ev in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/template/markup.py", line 362, in _match
    content = list(content)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/template/base.py", line 545, in _flatten
    for kind, data, pos in stream:
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/core.py", line 272, in _ensure
    event = stream.next()
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/template/directives.py", line 302, in function
    val = _eval_expr(self.defaults.get(name), ctxt, vars)
  File "/home/geordan/venv/testing/lib/python2.7/site-packages/genshi/template/base.py", line 277, in _eval_expr
    retval = expr.evaluate(ctxt)
AttributeError: 'NoneType' object has no attribute 'evaluate'

This error should be more verbose.

Change History (2)

comment:1 Changed 10 years ago by anonymous

Same thing happens when you use

<!-- want to strip this node and all sub-nodes -->
<p py:if=""> ... content here ... </p>

one could assume that py:if's condition works similar to py:strip, as in, an empty condition is interpreted as true and means "always strip". But results a very similar error as above.

comment:2 Changed 7 years ago by hodgestar

  • Milestone changed from 0.7 to 0.9

Moved to milestone 0.9.

Note: See TracTickets for help on using tickets.