The new support for default=drop just doesn't work #139

damz opened this Issue Sep 3, 2013 · 5 comments


None yet

3 participants

damz commented Sep 3, 2013

Just copy-pasting the example from CHANGES.txt:

import colander

class What(colander.MappingSchema):
    thing = colander.SchemaNode(colander.String(), default=colander.drop,

result = What().serialize({}) # no "thing" in mapping
assert result == {}

Result is actually:

{'thing': u'<colander._drop object at 0x1f26190>'}

(ie. the drop object cast to a string)

damz commented Sep 3, 2013

Sorry for the partial issue, prematurely hit the submit button.

damz commented Sep 3, 2013

This is because the value is changed to the default only in SchemaNode.serialize. As a consequence, the serialization is still called on the marker.

I only see two (possibly complementary) options:

(a) Short-circuit the serialization, like it's already the case for deserialization
(b) Have all possible types add support for the drop marker


Is this unreleased or something? Are you using the latest version released on pypi yesterday?

damz commented Sep 3, 2013

The test targets something else: serializing a appstruct that already has a drop value. The use case that is described in CHANGES.txt is not properly tested.

Yes, I am using 1.0b1.

@claytron claytron added a commit to claytron/colander that referenced this issue Feb 9, 2014
@claytron claytron fix serialization of default with drop
fixes #139
@jayd3e jayd3e closed this in #167 Feb 9, 2014
mcdonc commented Feb 9, 2014


@tseaver tseaver added a commit that referenced this issue Nov 26, 2014
@claytron @tseaver claytron + tseaver fix serialization of default with drop
fixes #139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment