[PATCH 1/3] Add ASCII-only upper and lower string functions.

Brian C. Lane bcl at redhat.com
Thu Aug 15 23:55:18 UTC 2013


On Thu, Aug 15, 2013 at 03:09:54PM -0400, David Shea wrote:

> +def upperASCII(s):
> +    """Convert a string to uppercase using only ASCII character definitions.
> +
> +    The returned string will contain only ASCII characters. This function is
> +    locale-independent.
> +    """
> +    return string.translate(_toASCII(s), _ASCIIupper_table)
> +
> +def lowerASCII(s):
> +    """Convert a string to lowercase using only ASCII character definitions.
> +
> +    The returned string will contain only ASCII characters. This function is
> +    locale-independent.
> +    """
> +    return string.translate(_toASCII(s), _ASCIIlower_table)

I didn't think of this the last time I looked, but these are going
to need some input validation. They blow up with None, which may happen
since a number of the calls are using .get()

Some callers are expecting a string (eg. .startswith()) so returning ""
in those failure cases may be the right thing to do.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130815/da94c8bc/attachment-0001.sig>


More information about the anaconda-patches mailing list