Invalid.asdict() broken for colander.All() #2

mmerickel opened this Issue Mar 1, 2011 · 4 comments


None yet

5 participants


Invalid.asdict() fails to handle the list of messages returned by colander.All().

It should check if if hasattr(exc.msg, '__iter__') and do an extend instead of append or something similar.

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/", line 324, in getMessage
    msg = str(self.msg)
File "/Users/example/.virtualenvs/project/lib/python2.7/site-packages/colander-0.9.1-py2.7.egg/colander/", line 157, in __str__
    return pprint.pformat(self.asdict())
File "/Users/example/.virtualenvs/project/lib/python2.7/site-packages/colander-0.9.1-py2.7.egg/colander/", line 151, in asdict
    errors['.'.join(keyparts)] = '; '.join(interpolate(msgs))
TypeError: sequence item 0: expected string, list found
rhyek commented Apr 1, 2011

This seems to do the trick:

msgs2 = []
for msg in msgs:
    if hasattr(msg, '__iter__'):
        for m in msg:
errors['.'.join(keyparts)] = '; '.join(interpolate(msgs2))

Not very elegant, but there you go.

rhyek commented Apr 1, 2011

actually you can do
errors['.'.join(keyparts)] = interpolate(msgs2)
and that'll return a list of errors which to me is more useful, but i might be stepping on something i'm not aware of here.

dwt commented Feb 22, 2012

This just cost me this whole day, can you please estimate when this will be fixed?

rbu commented Feb 22, 2012

See also #22 and #12

@mcdonc mcdonc closed this in a6b85dd Feb 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment