def decode(string):
if not string:<EOL><INDENT>raise IncompleteData(string)<EOL><DEDENT>if string[<NUM_LIT:0>] != <NUM_LIT>:<EOL><INDENT>raise ValueError("<STR_LIT>" % string[<NUM_LIT:0>])<EOL><DEDENT>if string[<NUM_LIT:1>:<NUM_LIT:2>] == b'<STR_LIT:P>':<EOL><INDENT>if len(string) < <NUM_LIT:16>:<EOL><INDENT>raise IncompleteData(string)<EOL><DEDENT>d = decompressobj()<EOL>term_string = d.decompress(string[<NUM_LIT:6>:]) + d.flush()<EOL>uncompressed_size, = _int4_unpack(string[<NUM_LIT:2>:<NUM_LIT:6>])<EOL>if len(term_string) != uncompressed_size:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (uncompressed_size, len(term_string)))<EOL><DEDENT>term, _tail = decode_term(term_string)<EOL>return term, d.unused_data<EOL><DEDENT>return decode_term(string[<NUM_LIT:1>:])<EOL>
Decode Erlang external term.