[Python-ideas] Adding str.isascii() ?

INADA Naoki songofacandy at gmail.com
Fri Jan 26 06:17:23 EST 2018


> No, because you can pass in maxchar to PyUnicode_New() and
> the implementation will take this as hint to the max code point
> used in the string. There is no check done whether maxchar
> is indeed the minimum upper bound to the code point ordinals.

API doc says:

"""
maxchar should be the true maximum code point to be placed in the string.
As an approximation, it can be rounded up to the nearest value in the
sequence 127, 255, 65535, 1114111.
"""
https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_New

Since doc says *should*, strings created with wrong maxchar
are considered invalid object.

We already ignores string with wrong maxchars in some places.
Even "a" == "a" may fail for such invalid string object.

So I don't think str.iascii() should consider about it.

Regards,


More information about the Python-ideas mailing list