mutagen/_vorbis.py
def validate(self):
        """Validate keys and values.

        Check to make sure every key used is a valid Vorbis key, and
        that every value used is a valid Unicode or UTF-8 string. If
        any invalid keys or values are found, a ValueError is raised.

        In Python 3 all keys and values have to be a string.
        """

        # be stricter in Python 3
        if PY3:
            if not isinstance(self.vendor, text_type):
                raise ValueError
            for key, value in self:
                if not isinstance(key, text_type):
                    raise ValueError
                if not isinstance(value, text_type):
                    raise ValueError

        if not isinstance(self.vendor, text_type):
            try:
                self.vendor.decode('utf-8')
            except UnicodeDecodeError:
                raise ValueError

        for key, value in self._internal:
            try:
                if not is_valid_key(key):
                    raise ValueError
            except:
                raise ValueError("%r is not a valid key" % key)

            if not isinstance(value, text_type):
                try:
                    value.decode("utf-8")
                except:
                    raise ValueError("%r is not a valid value" % value)
        else:
            return True
def validate(self):
        # be stricter in Python 3
        if PY3:
            if not isinstance(self.vendor, text_type):
                raise ValueError
            for key, value in self:
                if not isinstance(key, text_type):
                    raise ValueError
                if not isinstance(value, text_type):
                    raise ValueError

        if not isinstance(self.vendor, text_type):
            try:
                self.vendor.decode('utf-8')
            except UnicodeDecodeError:
                raise ValueError

        for key, value in self._internal:
            try:
                if not is_valid_key(key):
                    raise ValueError
            except:
                raise ValueError("%r is not a valid key" % key)

            if not isinstance(value, text_type):
                try:
                    value.decode("utf-8")
                except:
                    raise ValueError("%r is not a valid value" % value)
        else:
            return True
def validate ( self ) : # be stricter in Python 3 if PY3 : if not isinstance ( self . vendor , text_type ) : raise ValueError for key , value in self : if not isinstance ( key , text_type ) : raise ValueError if not isinstance ( value , text_type ) : raise ValueError if not isinstance ( self . vendor , text_type ) : try : self . vendor . decode ( 'utf-8' ) except UnicodeDecodeError : raise ValueError for key , value in self . _internal : try : if not is_valid_key ( key ) : raise ValueError except : raise ValueError ( "%r is not a valid key" % key ) if not isinstance ( value , text_type ) : try : value . decode ( "utf-8" ) except : raise ValueError ( "%r is not a valid value" % value ) else : return True
Validate keys and values.

        Check to make sure every key used is a valid Vorbis key, and
        that every value used is a valid Unicode or UTF-8 string. If
        any invalid keys or values are found, a ValueError is raised.

        In Python 3 all keys and values have to be a string.
Validate keys and values .