def decode_union_old(self, data_type, obj):
val = None<EOL>if isinstance(obj, six.string_types):<EOL><INDENT>tag = obj<EOL>if data_type.definition._is_tag_present(tag, self.caller_permissions):<EOL><INDENT>val_data_type = data_type.definition._get_val_data_type(tag,<EOL>self.caller_permissions)<EOL>if not isinstance(val_data_type, (bv.Void, bv.Nullable)):<EOL><INDENT>raise bv.ValidationError(<EOL>"<STR_LIT>" % tag)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not self.strict and data_type.definition._catch_all:<EOL><INDENT>tag = data_type.definition._catch_all<EOL><DEDENT>else:<EOL><INDENT>raise bv.ValidationError("<STR_LIT>" % tag)<EOL><DEDENT><DEDENT><DEDENT>elif isinstance(obj, dict):<EOL><INDENT>if len(obj) != <NUM_LIT:1>:<EOL><INDENT>raise bv.ValidationError('<STR_LIT>' % len(obj))<EOL><DEDENT>tag = list(obj)[<NUM_LIT:0>]<EOL>raw_val = obj[tag]<EOL>if data_type.definition._is_tag_present(tag, self.caller_permissions):<EOL><INDENT>val_data_type = data_type.definition._get_val_data_type(tag,<EOL>self.caller_permissions)<EOL>if isinstance(val_data_type, bv.Nullable) and raw_val is None:<EOL><INDENT>val = None<EOL><DEDENT>elif isinstance(val_data_type, bv.Void):<EOL><INDENT>if raw_val is None or not self.strict:<EOL><INDENT>val = None<EOL><DEDENT>else:<EOL><INDENT>raise bv.ValidationError('<STR_LIT>' %<EOL>bv.generic_type_name(raw_val))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>val = self.json_compat_obj_decode_helper(val_data_type, raw_val)<EOL><DEDENT>except bv.ValidationError as e:<EOL><INDENT>e.add_parent(tag)<EOL>raise<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if not self.strict and data_type.definition._catch_all:<EOL><INDENT>tag = data_type.definition._catch_all<EOL><DEDENT>else:<EOL><INDENT>raise bv.ValidationError("<STR_LIT>" % tag)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise bv.ValidationError("<STR_LIT>" %<EOL>bv.generic_type_name(obj))<EOL><DEDENT>return data_type.definition(tag, val)<EOL>
The data_type argument must be a Union.
See json_compat_obj_decode() for argument descriptions.