diff --git a/colander/__init__.py b/colander/__init__.py index 20521c31..636086a4 100644 --- a/colander/__init__.py +++ b/colander/__init__.py @@ -982,7 +982,7 @@ def __init__(self, encoding=None): self.encoding = encoding def serialize(self, node, appstruct): - if not appstruct: + if appstruct in (null, None): return null try: diff --git a/colander/tests/test_colander.py b/colander/tests/test_colander.py index cc159e88..c18f216e 100644 --- a/colander/tests/test_colander.py +++ b/colander/tests/test_colander.py @@ -1182,6 +1182,14 @@ def test_serialize_none(self): result = typ.serialize(node, val) self.assertEqual(result, colander.null) + def test_serialize_emptystring(self): + import colander + val = u'' + node = DummySchemaNode(None) + typ = self._makeOne() + result = typ.serialize(node, val) + self.assertEqual(result, val) + def test_serialize_uncooperative(self): val = Uncooperative() node = DummySchemaNode(None)