'Check if the given thing is an ascii-only string.
Raises ValidationError if not.
Args:
value: The value to check.
what: Either \'key\' or \'value\'.'

def _validate_str(self, value, what):

    if (not isinstance(value, str)):
        msg = 'Expected    string    for    {}    {!r}    but    got    {}'.format(what, value, type(value))
        raise configexc.ValidationError(value, msg)
    try:
        value.encode('ascii')
    except UnicodeEncodeError as e:
        msg = '{}    {!r}    contains    non-ascii    characters:    {}'.format(what.capitalize(), value, e)
        raise configexc.ValidationError(value, msg)
