Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number cannot serialize None and Datetime serializes None to colander.null #186

Open
ny2ko opened this issue Aug 27, 2014 · 3 comments
Open

Comments

@ny2ko
Copy link

ny2ko commented Aug 27, 2014

I would like to know why Int (Number generally) cannot deserialize None i.e. serialize None to None. This used to be the case in previous versions of colander but it seems to have been removed. Instead now it fails on the call to int(None). Was there a reason for this design change?

Also DateTime serializes None to colander.null. This has been changed for most other types to only serialized colander.null to colander.null by:

def serialize(self, node, appstruct):
        if appstruct is null:
            return null

Is there a reason why DateTime is any different?

@jaseemabid
Copy link
Contributor

@ny2ko I'd rather have number type always give me a number, and not None. Think static typing. The only case where I'd want None to be converted to None would be when I explicitly specify missing to None.

</ Personal Opinion>

@tisdall
Copy link
Contributor

tisdall commented Jan 29, 2015

I'm confused too... It seems the Number functionality was reverted in 513d860 but I can't seem to see any comments as to why the change was made. @mcdonc since you committed that, can you comment on this? The previous behaviour was to treat both None and colander.null as colander.null. This seems to make sense with respect to the null documentation saying the purpose of colander.null is to represent a non-value in the cases where None is a valid value. If we're in a case where None isn't valid (as is the case for Numbers) why not make it work the same as colander.null?

@tisdall
Copy link
Contributor

tisdall commented Jan 29, 2015

related to #140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants