def decode(self, pdu):
        """Decode a tag from the PDU."""
        try:
            tag = pdu.get()

            # extract the type
            self.tagClass = (tag >> 3) & 0x01

            # extract the tag number
            self.tagNumber = (tag >> 4)
            if (self.tagNumber == 0x0F):
                self.tagNumber = pdu.get()

            # extract the length
            self.tagLVT = tag & 0x07
            if (self.tagLVT == 5):
                self.tagLVT = pdu.get()
                if (self.tagLVT == 254):
                    self.tagLVT = pdu.get_short()
                elif (self.tagLVT == 255):
                    self.tagLVT = pdu.get_long()
            elif (self.tagLVT == 6):
                self.tagClass = Tag.openingTagClass
                self.tagLVT = 0
            elif (self.tagLVT == 7):
                self.tagClass = Tag.closingTagClass
                self.tagLVT = 0

            # application tagged boolean has no more data
            if (self.tagClass == Tag.applicationTagClass) and (self.tagNumber == Tag.booleanAppTag):
                # tagLVT contains value
                self.tagData = ''
            else:
                # tagLVT contains length
                self.tagData = pdu.get_data(self.tagLVT)
        except DecodingError:
            raise InvalidTag("invalid tag encoding")
Decode a tag from the PDU.