def check_key(self, key, key_extra_len=<NUM_LIT:0>):
if isinstance(key, tuple): key = key[<NUM_LIT:1>]<EOL>if not key:<EOL><INDENT>raise Client.MemcachedKeyNoneError("<STR_LIT>")<EOL><DEDENT>if isinstance(key, str):<EOL><INDENT>raise Client.MemcachedStringEncodingError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if not isinstance(key, str):<EOL><INDENT>raise Client.MemcachedKeyTypeError("<STR_LIT>")<EOL><DEDENT>if isinstance(key, str):<EOL><INDENT>if self.server_max_key_length != <NUM_LIT:0> andlen(key) + key_extra_len > self.server_max_key_length:<EOL><INDENT>raise Client.MemcachedKeyLengthError("<STR_LIT>"<EOL>% self.server_max_key_length)<EOL><DEDENT>if not valid_key_chars_re.match(key):<EOL><INDENT>raise Client.MemcachedKeyCharacterError(<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>
Checks sanity of key.  Fails if:
            Key length is > SERVER_MAX_KEY_LENGTH (Raises MemcachedKeyLength).
            Contains control characters  (Raises MemcachedKeyCharacterError).
            Is not a string (Raises MemcachedStringEncodingError)
            Is an unicode string (Raises MemcachedStringEncodingError)
            Is not a string (Raises MemcachedKeyError)
            Is None (Raises MemcachedKeyError)