Code generation relies on positive id()

Bug #716954 reported by Alan Hoey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Chamelon Core
New
Undecided
Unassigned

Bug Description

When attempting to initially render a template I get a "can't assign to operator" syntax error. After the template has successfully rendered once it appears to work fine from then onwards.

Further investigation suggests that the problem is that there are multiple places in translation.py where variable names are generated using for example "_attrs_%d" % id(self.element)). If the result of id is negative, this creates an invalid name, which ultimately causes the error.

Chameleon-1.2.13
Python 2.4.6 (#2, Feb 11 2011, 10:33:37)
[GCC 4.4.3] on linux2

Revision history for this message
Marc Abramowitz (msabramo) wrote :

I am seeing what appears to be the same issue when running Pyramid's test suite on PyPy 1.9.0 on Ubuntu.

Stack traces: https://gist.github.com/2931176

The result of running the generated file (one_d1aff7bdf83cf7e7a25b2c56fdc91886eb87d7dc.py ) through Python:

    marca@ubuntu:~/dev/git-repos/pyramid$ python one_d1aff7bdf83cf7e7a25b2c56fdc91886eb87d7dc.py
      File "one_d1aff7bdf83cf7e7a25b2c56fdc91886eb87d7dc.py", line 3
        _static_-1226789952 = {u'xmlns': u'http://www.w3.org/1999/xhtml', }
    SyntaxError: can't assign to operator

and the contents of the file itself: https://gist.github.com/2931197

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.