malthe/chameleon — Issue #84: unhashable type in codegen
Author: mauritsvanrees
Created: 2012-01-04 22:11:55+00:00
State: open

In Plone 4.2 coredev using experimental/chameleon.cfg I get this error when I run `bin/test-pt -s plone.app.testing`:

```python

ZopeXMLConfigurationError: File "/Users/mauritsvanrees/shared-eggs/plone.z3cform-0.7.8-py2.6.egg/plone/z3cform/templates.zcml", line 9.6-9.34
ZopeXMLConfigurationError: File "/Users/mauritsvanrees/community/plone-coredev/4.2/src/five.pt/src/five/pt/configure.zcml", line 6.2-6.30
ZopeXMLConfigurationError: File "/Users/mauritsvanrees/community/plone-coredev/4.2/src/z3c.pt/src/z3c/pt/configure.zcml", line 11.4
TypeError: unhashable type: 'list'
```

It is a strange and extremely long traceback. The error is in `chameleon/codegen.py`:

```python
reverse_builtin_map = dict(
(value, name) for (name, value) in builtins.__dict__.items()
)
```

One of the values of the builtins is the list type and this cannot be used as key in a dict:

```python
>>> dict((k,v) for (k,v) in [(1,[])])
{1: []}
>>> dict((v,k) for (k,v) in [(1,[])])
Traceback (most recent call last):
File "", line 1, in
TypeError: unhashable type: 'list'
```

Maybe in other cases the builtins are completely different and there it works? I don't know what plone.app.testing has to do with it; this was simply one of the packages that failed when running `bin/alltests-pt`. `bin/test -s plone.app.testing` works fine. The tests for most other packages run fine with `bin/test-pt` though a few probably minor fixes need to be done. This one is beyond me though. :-)