mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342)
This commit is contained in:
parent
85527cf50a
commit
a49ac99029
13 changed files with 110 additions and 2 deletions
|
@ -11611,6 +11611,25 @@ unicode_index(PyObject *self, PyObject *args)
|
|||
return PyLong_FromSsize_t(result);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
str.isascii as unicode_isascii
|
||||
|
||||
Return True if all characters in the string are ASCII, False otherwise.
|
||||
|
||||
ASCII characters have code points in the range U+0000-U+007F.
|
||||
Empty string is ASCII too.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
unicode_isascii_impl(PyObject *self)
|
||||
/*[clinic end generated code: output=c5910d64b5a8003f input=5a43cbc6399621d5]*/
|
||||
{
|
||||
if (PyUnicode_READY(self) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
return PyBool_FromLong(PyUnicode_IS_ASCII(self));
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
str.islower as unicode_islower
|
||||
|
||||
|
@ -13801,6 +13820,7 @@ static PyMethodDef unicode_methods[] = {
|
|||
UNICODE_UPPER_METHODDEF
|
||||
{"startswith", (PyCFunction) unicode_startswith, METH_VARARGS, startswith__doc__},
|
||||
{"endswith", (PyCFunction) unicode_endswith, METH_VARARGS, endswith__doc__},
|
||||
UNICODE_ISASCII_METHODDEF
|
||||
UNICODE_ISLOWER_METHODDEF
|
||||
UNICODE_ISUPPER_METHODDEF
|
||||
UNICODE_ISTITLE_METHODDEF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue