def _unpack_by_int(self, data, current_position):
<EOL>try:<EOL><INDENT>requested_data_length = struct.unpack('<STR_LIT>', data[current_position:current_position + self.INT_LEN])[<NUM_LIT:0>]<EOL><DEDENT>except struct.error:<EOL><INDENT>raise MalformedDataError("<STR_LIT>" % self.INT_LEN)<EOL><DEDENT>current_position += self.INT_LEN<EOL>remaining_data_length = len(data[current_position:])<EOL>if remaining_data_length < requested_data_length:<EOL><INDENT>raise MalformedDataError(<EOL>"<STR_LIT>" % (requested_data_length, remaining_data_length)<EOL>)<EOL><DEDENT>next_data = data[current_position:current_position + requested_data_length]<EOL>current_position += requested_data_length<EOL>return current_position, next_data<EOL>
Returns a tuple with (location of next data field, contents of requested data field).