Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use of exists: with erroneous code shows incorrect error in page template #129

Open
davidjb opened this Issue · 0 comments

1 participant

@davidjb

By including this:

    <tal:block condition="exists:form">
    ...
    </tal:block>

in a page template, it appears that any error that occurs on the page, such as by including this problematic snippet:

${''.join([1,2,3])}

produces an incorrect traceback:

File "/home/david/.buildout/eggs/Chameleon-2.10-py2.7.egg/chameleon/template.py", line 125, in __call__
    return self.render(**kwargs)
  File "/home/david/.buildout/eggs/Chameleon-2.10-py2.7.egg/chameleon/zpt/template.py", line 257, in render
    return super(PageTemplate, self).render(**vars)
  File "/home/david/.buildout/eggs/Chameleon-2.10-py2.7.egg/chameleon/template.py", line 190, in render
    raise_with_traceback(exc, tb)
  File "/home/david/.buildout/eggs/Chameleon-2.10-py2.7.egg/chameleon/template.py", line 172, in render
    self._render(stream, econtext, rcontext)
  File "/tmp/tmpla4Pzm/profile_0a115cc2a1476969f981b6e5a3415492d4e5f193.py", line 2656, in render
    __macro.include(__stream, econtext.copy(), rcontext, __i18n_domain)
  File "/home/david/.buildout/eggs/Chameleon-2.10-py2.7.egg/chameleon/zpt/template.py", line 261, in include
    self._render(*args, **kwargs)
  File "/tmp/tmpNoXbaT/master_0dcd06fbeaf411b3407adc5bb4a14f8088378967.py", line 726, in render
    __slot_content(__stream, econtext.copy(), rcontext)
  File "/tmp/tmpla4Pzm/profile_0a115cc2a1476969f981b6e5a3415492d4e5f193.py", line 641, in __fill_content
    __content_140487793025840 = _lookup_attr('', 'join')([1, 2, 3, ])
TypeError: form

 - Expression: "
      ${''.join([1,2,3])}
      "
 - Filename:   ... files/src/templates/profile.pt
 - Location:   (45:18)
 - Source:     </tal:block>
                           ^
 - Expression: "form"
 - Filename:   ... files/src/templates/profile.pt
 - Location:   (43:35)
 - Source:     <tal:block condition="exists:form">
                                            ^^^^

Previously the Expression was incorrect too (clearly referencing the exists: statement) but I can't seem to reproduce this yet. As shown, the location, source and expression reference the exists:.

After removing the exists: tal:block, the correct error is output:

TypeError: sequence item 0: expected string, int found

 - Expression: "
      ${''.join([1,2,3])}
      "
 - Filename:   ... files/src/templates/profile.pt
 - Location:   (42:12)
 - Source:     </div>
                     ^

Tested in Chameleon 2.10 and Python 2.7 (with Pyramid 1.4a2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.