Permalink
Browse files

use colander.compat.is_nonstr_iter

  • Loading branch information...
1 parent 7338243 commit 554758b0c3a029f171df9a1f8e6c3fffaa6ea232 @domenkozar domenkozar committed Nov 10, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 colander/__init__.py
  2. +6 −0 colander/tests/test_colander.py
View
@@ -755,7 +755,7 @@ def deserialize(self, node, cstruct):
if cstruct is null:
return null
- if not hasattr(cstruct, '__iter__'):
+ if not is_nonstr_iter(cstruct):
raise Invalid(
node,
_('${cstruct} is not iterable', mapping={'cstruct': cstruct})
@@ -975,6 +975,12 @@ def test_deserialize_no_iter(self):
e = invalid_exc(typ.deserialize, node, 1)
self.assertEqual(e.msg, '${cstruct} is not iterable')
+ def test_deserialize_str_no_iter(self):
+ typ = self._makeOne()
+ node = DummySchemaNode(typ)
+ e = invalid_exc(typ.deserialize, node, "foo")
+ self.assertEqual(e.msg, '${cstruct} is not iterable')
+
def test_deserialize_null(self):
from colander import null
typ = self._makeOne()

0 comments on commit 554758b

Please sign in to comment.