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

incompatibility - empty optional attributes are None instead of not existing #11

Open
oranch opened this issue Jul 13, 2011 · 2 comments

Comments

@oranch
Copy link

oranch commented Jul 13, 2011

When parsing a message, optional attributes which don't have a value are created with a None value.
This is incompatible with the Google implementation, which does not create the attribute at all.

BTW this tool is great - keep up the good work :-)

@oranch
Copy link
Author

oranch commented Jul 13, 2011

I'm far from an expert on writing Python types, but looking at the code, I realize that getting hasattr() and getattr() right might be tricky, especially for native types where you can't use NULL in c++.

An easier improvement to compatibility would be to add new fields to the python class, named has - one for each optional attribute.

Such fields exist in the Google python implementation, so users would be able to safely alternate between the two implementations if they rely on these fields to test the existence of a value rather than on hasattr()

@oranch
Copy link
Author

oranch commented Jul 13, 2011

the comment system slightly messed up my last comment :-(
the field name is _has_xxxx for an attribute name of xxxx.

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

1 participant