Fix problem with uninitialized unions in _from_dict

This commit is contained in:
Jason Paryani
2014-02-18 17:34:34 -08:00
parent 110b454e2c
commit 307fcbf4e7
3 changed files with 18 additions and 2 deletions

View File

@@ -741,7 +741,12 @@ cdef _to_dict(msg, bint verbose):
cdef _from_dict(_DynamicStructBuilder msg, dict d):
for key, val in d.iteritems():
if key != 'which':
msg._set(key, val)
try:
msg._set(key, val)
except Exception as e:
if 'expected isSetInUnion(field)' in str(e):
msg.init(key)
msg._set(key, val)
cdef _from_list(_DynamicListBuilder msg, list d):
cdef size_t count = 0