Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Invalid.messages() should return an empty list if there are no messages #21

wants to merge 1 commit into from

2 participants


Currently, the messages method of Invalid returns [None] (a list of length one) if the msg attribute is None. This seems non-useful. This fixes things so that an empty list is returned when there are no messages.

@mcdonc mcdonc closed this in 8f16140

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 2 deletions.
  1. +3 −0  CHANGES.txt
  2. +5 −2 colander/
  3. +5 −0 colander/
3  CHANGES.txt
@@ -17,6 +17,9 @@ Unreleased
- Added ``get_value`` and ``set_value`` methods to ``Schema`` which allow
access and mutation of appstructs using dotted name paths.
+- The ``messages`` method of ``Invalid`` now returns an empty list
+ when there are no messages.
0.9.3 (2011-06-23)
7 colander/
@@ -62,10 +62,13 @@ def messages(self):
""" Return an iterable of error messages for this exception
using the ``msg`` attribute of this error node. If the
``msg`` attribute is iterable, it is returned. If it is not
- iterable, a single-element list containing the ``msg`` value
- is returned."""
+ iterable, and is not ``None``, a single-element list
+ containing the ``msg`` value is returned. If ``msg`` is ``None``,
+ an empty list is returned."""
if hasattr(self.msg, '__iter__'):
return self.msg
+ elif self.msg is None:
+ return []
return [self.msg]
def add(self, exc, pos=None):
5 colander/
@@ -136,6 +136,11 @@ def test_messages_msg_not_iterable(self):
exc = self._makeOne(node, 'msg')
self.assertEqual(exc.messages(), ['msg'])
+ def test_messages_msg_none(self):
+ node = DummySchemaNode(None)
+ exc = self._makeOne(node)
+ self.assertEqual(exc.messages(), [])
class TestAll(unittest.TestCase):
def _makeOne(self, validators):
from colander import All
Something went wrong with that request. Please try again.