[Mailman-Users] TypeError: list objects are unhashable

Joshua J. Kugler joshua at eeinternet.com
Wed Jan 19 19:53:51 CET 2011


On Wednesday 19 January 2011, Mark Sapiro elucidated thus:
> Alain Williams wrote:
> >The traceback is below, since I don't speak python it doesn't mean
> > much to me. The list works, but the error below appears when anyone
> > enters their email address and tries to see their subscrition
> > options.
> >
> >I would be grateful if someone could give me some pointers as to
> > what I have done wrong.
> >
> >Many thanks.
> >
> >
> >admin(21868): [----- Mailman Version: 2.1.9 -----]
> >admin(21868): [----- Traceback ------]
> >admin(21868): Traceback (most recent call last):
> >admin(21868):   File "/usr/local/mailman/fridayfolk/scripts/driver",
> > line 101, in run_main admin(21868):     main()
> >admin(21868):   File
> > "/usr/local/mailman/fridayfolk/Mailman/Cgi/options.py", line 93, in
> > main admin(21868):     if not Utils.IsLanguage(language):
> >admin(21868):   File
> > "/usr/local/mailman/fridayfolk/Mailman/Utils.py", line 678, in
> > IsLanguage admin(21868):     return
> > mm_cfg.LC_DESCRIPTIONS.has_key(lang) admin(21868): TypeError: list
> > objects are unhashable
>
> Someone has (hopefully in mm_cfg.py, but possibly by editing
> Defaults.py) redefined LC_DESCRIPTIONS as a list instead of a
> dictionary.

Actually, wouldn't 'lang' be the culprit here, as that is what is not 
hashable?  If LC_DESCRIPTIONS was a list, the error would be:

AttributeError: 'list' object has no attribute 'has_key'

>>> d = {}
>>> d.has_key([1,2,3])
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: unhashable type: 'list'
>>> x = []
>>> x.has_key
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'list' object has no attribute 'has_key'
>>>


> If you don't know how to fix this, post your mm_cfg.py, and, if
> you've made changes to Defaults.py, see the FAQ at
> <http://wiki.list.org/x/fIA9> and post those too.
>
> Note that in any case, if you have something like
>
> LC_DESCRIPTIONS = []
>
> in mm_cfg.py, that is wrong on two counts. LC_DESCRIPTIONS is a
> dictionary and an empty dictionary is {}, not [], and if
> LC_DESCRIPTIONS is redefined in mm_cfg.py, add_language() will still
> update the original dictionary.
>
> The correct thing to put in mm_cfg.py for Mailman 2.1.9 if you want
> say English as the only language is
>
> LC_DESCRIPTIONS.clear()
> add_language('en', 'English (USA)', 'us-ascii')



-- 
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/  ID 0x73B13B6A


More information about the Mailman-Users mailing list