diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -2,6 +2,785 @@ preserve [clinic start generated code]*/ +PyDoc_STRVAR(unicode_title__doc__, +"title($self, /)\n" +"--\n" +"\n" +"Return a version of the string where each word is capitalized.\n" +"\n" +"More specifically, words start with upper cased characters and all remaining\n" +"cased characters have lower case."); + +#define UNICODE_TITLE_METHODDEF \ + {"title", (PyCFunction)unicode_title, METH_NOARGS, unicode_title__doc__}, + +static PyObject * +unicode_title_impl(PyUnicodeObject *self); + +static PyObject * +unicode_title(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_title_impl(self); +} + +PyDoc_STRVAR(unicode_capitalize__doc__, +"capitalize($self, /)\n" +"--\n" +"\n" +"Return a capitalized version of the string.\n" +"\n" +"More specifically, make the first character have upper case and the rest lower\n" +"case."); + +#define UNICODE_CAPITALIZE_METHODDEF \ + {"capitalize", (PyCFunction)unicode_capitalize, METH_NOARGS, unicode_capitalize__doc__}, + +static PyObject * +unicode_capitalize_impl(PyUnicodeObject *self); + +static PyObject * +unicode_capitalize(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_capitalize_impl(self); +} + +PyDoc_STRVAR(unicode_casefold__doc__, +"casefold($self, /)\n" +"--\n" +"\n" +"Return a version of S suitable for caseless comparisons."); + +#define UNICODE_CASEFOLD_METHODDEF \ + {"casefold", (PyCFunction)unicode_casefold, METH_NOARGS, unicode_casefold__doc__}, + +static PyObject * +unicode_casefold_impl(PyUnicodeObject *self); + +static PyObject * +unicode_casefold(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_casefold_impl(self); +} + +PyDoc_STRVAR(unicode_center__doc__, +"center($self, width, fillchar=\' \', /)\n" +"--\n" +"\n" +"Return a centered string of length width.\n" +"\n" +"Padding is done using the specified fill character (default is a space)."); + +#define UNICODE_CENTER_METHODDEF \ + {"center", (PyCFunction)unicode_center, METH_VARARGS, unicode_center__doc__}, + +static PyObject * +unicode_center_impl(PyUnicodeObject *self, Py_ssize_t width, + Py_UCS4 fillchar); + +static PyObject * +unicode_center(PyUnicodeObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + Py_UCS4 fillchar = ' '; + + if (!PyArg_ParseTuple(args, + "n|O&:center", + &width, convert_uc, &fillchar)) + goto exit; + return_value = unicode_center_impl(self, width, fillchar); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_encode__doc__, +"encode($self, /, encoding=\'utf-8\', errors=\'strict\')\n" +"--\n" +"\n" +"Encode a string using the codec registered for encoding.\n" +"\n" +" encoding\n" +" The encoding in which to encode the string.\n" +" errors\n" +" The error handling scheme to use for the handling of encoding errors.\n" +" The default is \'strict\' meaning that encoding errors raise a\n" +" UnicodeEncodeError. Other possible values are \'ignore\', \'replace\' and\n" +" \'xmlcharrefreplace\' as well as any other name registered with\n" +" codecs.register_error that can handle UnicodeEncodeErrors."); + +#define UNICODE_ENCODE_METHODDEF \ + {"encode", (PyCFunction)unicode_encode, METH_VARARGS|METH_KEYWORDS, unicode_encode__doc__}, + +static PyObject * +unicode_encode_impl(PyUnicodeObject *self, const char *encoding, + const char *errors); + +static PyObject * +unicode_encode(PyUnicodeObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"encoding", "errors", NULL}; + const char *encoding = NULL; + const char *errors = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|ss:encode", _keywords, + &encoding, &errors)) + goto exit; + return_value = unicode_encode_impl(self, encoding, errors); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_expandtabs__doc__, +"expandtabs($self, /, tabsize=8)\n" +"--\n" +"\n" +"Return a copy where all tab characters are expanded using spaces.\n" +"\n" +"If tabsize is not given, a tab size of 8 characters is assumed."); + +#define UNICODE_EXPANDTABS_METHODDEF \ + {"expandtabs", (PyCFunction)unicode_expandtabs, METH_VARARGS|METH_KEYWORDS, unicode_expandtabs__doc__}, + +static PyObject * +unicode_expandtabs_impl(PyUnicodeObject *self, int tabsize); + +static PyObject * +unicode_expandtabs(PyUnicodeObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"tabsize", NULL}; + int tabsize = 8; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|i:expandtabs", _keywords, + &tabsize)) + goto exit; + return_value = unicode_expandtabs_impl(self, tabsize); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_islower__doc__, +"islower($self, /)\n" +"--\n" +"\n" +"Return whether the string is a lowercase string; False otherwise.\n" +"\n" +"A string is lowercase if all cased characters in the string are lowercase and\n" +"there is at least one cased character in the string."); + +#define UNICODE_ISLOWER_METHODDEF \ + {"islower", (PyCFunction)unicode_islower, METH_NOARGS, unicode_islower__doc__}, + +static PyObject * +unicode_islower_impl(PyUnicodeObject *self); + +static PyObject * +unicode_islower(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_islower_impl(self); +} + +PyDoc_STRVAR(unicode_isupper__doc__, +"isupper($self, /)\n" +"--\n" +"\n" +"Return True if the string is an uppercase string; False otherwise.\n" +"\n" +"A string is uppercase if all cased characters in the string are uppercase and\n" +"there is at least one cased character in the string."); + +#define UNICODE_ISUPPER_METHODDEF \ + {"isupper", (PyCFunction)unicode_isupper, METH_NOARGS, unicode_isupper__doc__}, + +static PyObject * +unicode_isupper_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isupper(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isupper_impl(self); +} + +PyDoc_STRVAR(unicode_istitle__doc__, +"istitle($self, /)\n" +"--\n" +"\n" +"Return True if the string is a title-cased string; False otherwise.\n" +"\n" +"In a title-cased string, upper- and title-case characters may only\n" +"follow uncased characters and lowercase characters only cased ones."); + +#define UNICODE_ISTITLE_METHODDEF \ + {"istitle", (PyCFunction)unicode_istitle, METH_NOARGS, unicode_istitle__doc__}, + +static PyObject * +unicode_istitle_impl(PyUnicodeObject *self); + +static PyObject * +unicode_istitle(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_istitle_impl(self); +} + +PyDoc_STRVAR(unicode_isspace__doc__, +"isspace($self, /)\n" +"--\n" +"\n" +"Return True if the string is a whitespace string; False otherwise.\n" +"\n" +"A string is whitespace if all characters in the string are whitespace and there\n" +"is at least one character in the string."); + +#define UNICODE_ISSPACE_METHODDEF \ + {"isspace", (PyCFunction)unicode_isspace, METH_NOARGS, unicode_isspace__doc__}, + +static PyObject * +unicode_isspace_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isspace(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isspace_impl(self); +} + +PyDoc_STRVAR(unicode_isalpha__doc__, +"isalpha($self, /)\n" +"--\n" +"\n" +"Return True if the string is an alphabetic string; False otherwise.\n" +"\n" +"A string is alphabetic if all characters in the string are alphabetic and there\n" +"is at least one character in the string."); + +#define UNICODE_ISALPHA_METHODDEF \ + {"isalpha", (PyCFunction)unicode_isalpha, METH_NOARGS, unicode_isalpha__doc__}, + +static PyObject * +unicode_isalpha_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isalpha(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isalpha_impl(self); +} + +PyDoc_STRVAR(unicode_isalnum__doc__, +"isalnum($self, /)\n" +"--\n" +"\n" +"Return True if the string is an alpha-numeric string; False otherwise.\n" +"\n" +"A string is alpha-numeric if all characters in the string are alpha-numeric and\n" +"there is at least one character in the string."); + +#define UNICODE_ISALNUM_METHODDEF \ + {"isalnum", (PyCFunction)unicode_isalnum, METH_NOARGS, unicode_isalnum__doc__}, + +static PyObject * +unicode_isalnum_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isalnum(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isalnum_impl(self); +} + +PyDoc_STRVAR(unicode_isdecimal__doc__, +"isdecimal($self, /)\n" +"--\n" +"\n" +"Return True if the string is a decimal string; False otherwise.\n" +"\n" +"A string is a digit string if all characters in the string are decimal and\n" +"there is at least one character in the string."); + +#define UNICODE_ISDECIMAL_METHODDEF \ + {"isdecimal", (PyCFunction)unicode_isdecimal, METH_NOARGS, unicode_isdecimal__doc__}, + +static PyObject * +unicode_isdecimal_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isdecimal(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isdecimal_impl(self); +} + +PyDoc_STRVAR(unicode_isdigit__doc__, +"isdigit($self, /)\n" +"--\n" +"\n" +"Return True if the string is a digit string; False otherwise.\n" +"\n" +"A string is a digit string if all characters in the string are digits and there\n" +"is at least one character in the string."); + +#define UNICODE_ISDIGIT_METHODDEF \ + {"isdigit", (PyCFunction)unicode_isdigit, METH_NOARGS, unicode_isdigit__doc__}, + +static PyObject * +unicode_isdigit_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isdigit(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isdigit_impl(self); +} + +PyDoc_STRVAR(unicode_isnumeric__doc__, +"isnumeric($self, /)\n" +"--\n" +"\n" +"Return True if the string is an numeric string; False otherwise.\n" +"\n" +"A string is numeric if all characters in the string are numeric and there is at\n" +"least one character in the string."); + +#define UNICODE_ISNUMERIC_METHODDEF \ + {"isnumeric", (PyCFunction)unicode_isnumeric, METH_NOARGS, unicode_isnumeric__doc__}, + +static PyObject * +unicode_isnumeric_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isnumeric(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isnumeric_impl(self); +} + +PyDoc_STRVAR(unicode_isidentifier__doc__, +"isidentifier($self, /)\n" +"--\n" +"\n" +"Return True if the string is a valid Python identifier; False otherwise.\n" +"\n" +"Use keyword.iskeyword() to test for reserved identifiers such as \"def\" and\n" +"\"class\"."); + +#define UNICODE_ISIDENTIFIER_METHODDEF \ + {"isidentifier", (PyCFunction)unicode_isidentifier, METH_NOARGS, unicode_isidentifier__doc__}, + +static PyObject * +unicode_isidentifier_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isidentifier(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isidentifier_impl(self); +} + +PyDoc_STRVAR(unicode_isprintable__doc__, +"isprintable($self, /)\n" +"--\n" +"\n" +"Return True if the string is printable; False otherwise.\n" +"\n" +"A string is printable if all of its characters are considered printable in\n" +"repr() or if it is empty."); + +#define UNICODE_ISPRINTABLE_METHODDEF \ + {"isprintable", (PyCFunction)unicode_isprintable, METH_NOARGS, unicode_isprintable__doc__}, + +static PyObject * +unicode_isprintable_impl(PyUnicodeObject *self); + +static PyObject * +unicode_isprintable(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isprintable_impl(self); +} + +PyDoc_STRVAR(unicode_join__doc__, +"join($self, iterable, /)\n" +"--\n" +"\n" +"Concatenate any number of strings.\n" +"\n" +"The string whose method is called is inserted in between each pair of given\n" +"strings.\n" +"\n" +"The result is returned as a new string.\n" +"\n" +"Example: \'.\'.join([\'ab\', \'pq\', \'rs\']) -> \'ab.pq.rs\'"); + +#define UNICODE_JOIN_METHODDEF \ + {"join", (PyCFunction)unicode_join, METH_O, unicode_join__doc__}, + +PyDoc_STRVAR(unicode_ljust__doc__, +"ljust($self, width, fillchar=\' \', /)\n" +"--\n" +"\n" +"Return a left-justified string of length width.\n" +"\n" +"Padding is done using the specified fill character (default is a space)."); + +#define UNICODE_LJUST_METHODDEF \ + {"ljust", (PyCFunction)unicode_ljust, METH_VARARGS, unicode_ljust__doc__}, + +static PyObject * +unicode_ljust_impl(PyUnicodeObject *self, Py_ssize_t width, Py_UCS4 fillchar); + +static PyObject * +unicode_ljust(PyUnicodeObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + Py_UCS4 fillchar = ' '; + + if (!PyArg_ParseTuple(args, + "n|O&:ljust", + &width, convert_uc, &fillchar)) + goto exit; + return_value = unicode_ljust_impl(self, width, fillchar); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_lower__doc__, +"lower($self, /)\n" +"--\n" +"\n" +"Return a copy of the string converted to lowercase."); + +#define UNICODE_LOWER_METHODDEF \ + {"lower", (PyCFunction)unicode_lower, METH_NOARGS, unicode_lower__doc__}, + +static PyObject * +unicode_lower_impl(PyUnicodeObject *self); + +static PyObject * +unicode_lower(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_lower_impl(self); +} + +PyDoc_STRVAR(unicode_strip__doc__, +"strip($self, chars=None, /)\n" +"--\n" +"\n" +"Return a copy of the string with leading and trailing whitespace removed.\n" +"\n" +"If chars is given and not None, remove characters in chars instead."); + +#define UNICODE_STRIP_METHODDEF \ + {"strip", (PyCFunction)unicode_strip, METH_VARARGS, unicode_strip__doc__}, + +static PyObject * +unicode_strip_impl(PyUnicodeObject *self, PyObject *chars); + +static PyObject * +unicode_strip(PyUnicodeObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *chars = NULL; + + if (!PyArg_UnpackTuple(args, "strip", + 0, 1, + &chars)) + goto exit; + return_value = unicode_strip_impl(self, chars); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_lstrip__doc__, +"lstrip($self, chars=None, /)\n" +"--\n" +"\n" +"Return a copy of the string with leading whitespace removed.\n" +"\n" +"If chars is given and not None, remove characters in chars instead."); + +#define UNICODE_LSTRIP_METHODDEF \ + {"lstrip", (PyCFunction)unicode_lstrip, METH_VARARGS, unicode_lstrip__doc__}, + +static PyObject * +unicode_lstrip_impl(PyUnicodeObject *self, PyObject *chars); + +static PyObject * +unicode_lstrip(PyUnicodeObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *chars = NULL; + + if (!PyArg_UnpackTuple(args, "lstrip", + 0, 1, + &chars)) + goto exit; + return_value = unicode_lstrip_impl(self, chars); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_rstrip__doc__, +"rstrip($self, chars=None, /)\n" +"--\n" +"\n" +"Return a copy of the string with trailing whitespace removed.\n" +"\n" +"If chars is given and not None, remove characters in chars instead."); + +#define UNICODE_RSTRIP_METHODDEF \ + {"rstrip", (PyCFunction)unicode_rstrip, METH_VARARGS, unicode_rstrip__doc__}, + +static PyObject * +unicode_rstrip_impl(PyUnicodeObject *self, PyObject *chars); + +static PyObject * +unicode_rstrip(PyUnicodeObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *chars = NULL; + + if (!PyArg_UnpackTuple(args, "rstrip", + 0, 1, + &chars)) + goto exit; + return_value = unicode_rstrip_impl(self, chars); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_replace__doc__, +"replace($self, old, new, count=-1, /)\n" +"--\n" +"\n" +"Return a copy with all occurrences of substring old replaced by new.\n" +"\n" +" count\n" +" Maximum number of occurrences to replace.\n" +" -1 (the default value) means replace all occurrences.\n" +"\n" +"If the optional argument count is given, only the first count occurrences are\n" +"replaced."); + +#define UNICODE_REPLACE_METHODDEF \ + {"replace", (PyCFunction)unicode_replace, METH_VARARGS, unicode_replace__doc__}, + +static PyObject * +unicode_replace_impl(PyUnicodeObject *self, PyObject *old, PyObject *new, + Py_ssize_t count); + +static PyObject * +unicode_replace(PyUnicodeObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *old; + PyObject *new; + Py_ssize_t count = -1; + + if (!PyArg_ParseTuple(args, + "OO|n:replace", + &old, &new, &count)) + goto exit; + return_value = unicode_replace_impl(self, old, new, count); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_rjust__doc__, +"rjust($self, width, fillchar=\' \', /)\n" +"--\n" +"\n" +"Return a right-justified string of length width.\n" +"\n" +"Padding is done using the specified fill character (default is a space)."); + +#define UNICODE_RJUST_METHODDEF \ + {"rjust", (PyCFunction)unicode_rjust, METH_VARARGS, unicode_rjust__doc__}, + +static PyObject * +unicode_rjust_impl(PyUnicodeObject *self, Py_ssize_t width, Py_UCS4 fillchar); + +static PyObject * +unicode_rjust(PyUnicodeObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + Py_UCS4 fillchar = ' '; + + if (!PyArg_ParseTuple(args, + "n|O&:rjust", + &width, convert_uc, &fillchar)) + goto exit; + return_value = unicode_rjust_impl(self, width, fillchar); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_split__doc__, +"split($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the words in the string, using sep as the delimiter string.\n" +"\n" +" sep\n" +" The delimiter according which to split the string.\n" +" None (the default value) means split according to any whitespace,\n" +" and discard empty strings from the result.\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit."); + +#define UNICODE_SPLIT_METHODDEF \ + {"split", (PyCFunction)unicode_split, METH_VARARGS|METH_KEYWORDS, unicode_split__doc__}, + +static PyObject * +unicode_split_impl(PyUnicodeObject *self, PyObject *sep, Py_ssize_t maxsplit); + +static PyObject * +unicode_split(PyUnicodeObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"sep", "maxsplit", NULL}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|On:split", _keywords, + &sep, &maxsplit)) + goto exit; + return_value = unicode_split_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_partition__doc__, +"partition($self, separator, /)\n" +"--\n" +"\n" +"Partition the string into three parts using the given separator.\n" +"\n" +"This will search for the separator in the string. If the separator is found,\n" +"returns a 3-tuple containing the part before the separator, the separator\n" +"itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing the original string\n" +"and two empty strings."); + +#define UNICODE_PARTITION_METHODDEF \ + {"partition", (PyCFunction)unicode_partition, METH_O, unicode_partition__doc__}, + +PyDoc_STRVAR(unicode_rpartition__doc__, +"rpartition($self, separator, /)\n" +"--\n" +"\n" +"Partition the string into three parts using the given separator.\n" +"\n" +"This will search for the separator in the string, starting and the end. If\n" +"the separator is found, returns a 3-tuple containing the part before the\n" +"separator, the separator itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing two empty strings\n" +"and the original string."); + +#define UNICODE_RPARTITION_METHODDEF \ + {"rpartition", (PyCFunction)unicode_rpartition, METH_O, unicode_rpartition__doc__}, + +PyDoc_STRVAR(unicode_rsplit__doc__, +"rsplit($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the words in the string, using sep as the delimiter string.\n" +"\n" +" sep\n" +" The delimiter according which to split the string.\n" +" None (the default value) means split according to any whitespace,\n" +" and discard empty strings from the result.\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit.\n" +"\n" +"Splits are done starting at the end of the string and working to the front."); + +#define UNICODE_RSPLIT_METHODDEF \ + {"rsplit", (PyCFunction)unicode_rsplit, METH_VARARGS|METH_KEYWORDS, unicode_rsplit__doc__}, + +static PyObject * +unicode_rsplit_impl(PyUnicodeObject *self, PyObject *sep, + Py_ssize_t maxsplit); + +static PyObject * +unicode_rsplit(PyUnicodeObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"sep", "maxsplit", NULL}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|On:rsplit", _keywords, + &sep, &maxsplit)) + goto exit; + return_value = unicode_rsplit_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_splitlines__doc__, +"splitlines($self, /, keepends=False)\n" +"--\n" +"\n" +"Return a list of the lines in the string, breaking at line boundaries.\n" +"\n" +"Line breaks are not included in the resulting list unless keepends is given and\n" +"true."); + +#define UNICODE_SPLITLINES_METHODDEF \ + {"splitlines", (PyCFunction)unicode_splitlines, METH_VARARGS|METH_KEYWORDS, unicode_splitlines__doc__}, + +static PyObject * +unicode_splitlines_impl(PyUnicodeObject *self, int keepends); + +static PyObject * +unicode_splitlines(PyUnicodeObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"keepends", NULL}; + int keepends = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|i:splitlines", _keywords, + &keepends)) + goto exit; + return_value = unicode_splitlines_impl(self, keepends); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_swapcase__doc__, +"swapcase($self, /)\n" +"--\n" +"\n" +"Convert uppercase characters to lowercase and lowercase characters to uppercase."); + +#define UNICODE_SWAPCASE_METHODDEF \ + {"swapcase", (PyCFunction)unicode_swapcase, METH_NOARGS, unicode_swapcase__doc__}, + +static PyObject * +unicode_swapcase_impl(PyUnicodeObject *self); + +static PyObject * +unicode_swapcase(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_swapcase_impl(self); +} + PyDoc_STRVAR(unicode_maketrans__doc__, "maketrans(x, y=None, z=None, /)\n" "--\n" @@ -39,4 +818,115 @@ exit: return return_value; } -/*[clinic end generated code: output=4670413843c53055 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(unicode_translate__doc__, +"translate($self, table, /)\n" +"--\n" +"\n" +"Replace each character in the string using the given translation table.\n" +"\n" +" table\n" +" Translation table, which must be a mapping of Unicode ordinals to\n" +" Unicode ordinals, strings, or None.\n" +"\n" +"Characters not in the translation table are left untouched.\n" +"\n" +"Characters mapped to None are deleted."); + +#define UNICODE_TRANSLATE_METHODDEF \ + {"translate", (PyCFunction)unicode_translate, METH_O, unicode_translate__doc__}, + +PyDoc_STRVAR(unicode_upper__doc__, +"upper($self, /)\n" +"--\n" +"\n" +"Return a copy of the string converted to uppercase."); + +#define UNICODE_UPPER_METHODDEF \ + {"upper", (PyCFunction)unicode_upper, METH_NOARGS, unicode_upper__doc__}, + +static PyObject * +unicode_upper_impl(PyUnicodeObject *self); + +static PyObject * +unicode_upper(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_upper_impl(self); +} + +PyDoc_STRVAR(unicode_zfill__doc__, +"zfill($self, width, /)\n" +"--\n" +"\n" +"Pad a numeric string with zeros on the left, to fill a field of the given width.\n" +"\n" +"The original string is never truncated."); + +#define UNICODE_ZFILL_METHODDEF \ + {"zfill", (PyCFunction)unicode_zfill, METH_O, unicode_zfill__doc__}, + +static PyObject * +unicode_zfill_impl(PyUnicodeObject *self, Py_ssize_t width); + +static PyObject * +unicode_zfill(PyUnicodeObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + + if (!PyArg_Parse(arg, + "n:zfill", + &width)) + goto exit; + return_value = unicode_zfill_impl(self, width); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode___format____doc__, +"__format__($self, format_spec, /)\n" +"--\n" +"\n" +"Return a formatted version of S as described by format_spec."); + +#define UNICODE___FORMAT___METHODDEF \ + {"__format__", (PyCFunction)unicode___format__, METH_O, unicode___format____doc__}, + +static PyObject * +unicode___format___impl(PyUnicodeObject *self, PyObject *format_spec); + +static PyObject * +unicode___format__(PyUnicodeObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *format_spec; + + if (!PyArg_Parse(arg, + "U:__format__", + &format_spec)) + goto exit; + return_value = unicode___format___impl(self, format_spec); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_sizeof__doc__, +"__sizeof__($self, /)\n" +"--\n" +"\n" +"Return the size of the string in memory, in bytes."); + +#define UNICODE_SIZEOF_METHODDEF \ + {"__sizeof__", (PyCFunction)unicode_sizeof, METH_NOARGS, unicode_sizeof__doc__}, + +static PyObject * +unicode_sizeof_impl(PyUnicodeObject *self); + +static PyObject * +unicode_sizeof(PyUnicodeObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_sizeof_impl(self); +} +/*[clinic end generated code: output=ac4432246c401507 input=a9049054013a1b77]*/ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -52,6 +52,14 @@ [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=604e916854800fa8]*/ +/*[python input] +class Py_UCS4_converter(CConverter): + type = 'Py_UCS4' + converter = 'convert_uc' + +[python start generated code]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=057c690003152f7c]*/ + /* --- Globals ------------------------------------------------------------ NOTE: In the interpreter's initialization phase, some globals are currently @@ -10524,28 +10532,36 @@ /* --- Unicode Object Methods --------------------------------------------- */ -PyDoc_STRVAR(title__doc__, - "S.title() -> str\n\ -\n\ -Return a titlecased version of S, i.e. words start with title case\n\ -characters, all remaining cased characters have lower case."); - -static PyObject* -unicode_title(PyObject *self) +/*[clinic input] +str.title as unicode_title + +Return a version of the string where each word is capitalized. + +More specifically, words start with upper cased characters and all remaining +cased characters have lower case. +[clinic start generated code]*/ + +static PyObject * +unicode_title_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=05bffb9c18fa1f86 input=4eb12c1bb8642cb9]*/ { if (PyUnicode_READY(self) == -1) return NULL; return case_operation(self, do_title); } -PyDoc_STRVAR(capitalize__doc__, - "S.capitalize() -> str\n\ -\n\ -Return a capitalized version of S, i.e. make the first character\n\ -have upper case and the rest lower case."); - -static PyObject* -unicode_capitalize(PyObject *self) +/*[clinic input] +str.capitalize as unicode_capitalize + +Return a capitalized version of the string. + +More specifically, make the first character have upper case and the rest lower +case. +[clinic start generated code]*/ + +static PyObject * +unicode_capitalize_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=f7ebee083b805a9b input=f4cbf1016938da6d]*/ { if (PyUnicode_READY(self) == -1) return NULL; @@ -10554,13 +10570,15 @@ return case_operation(self, do_capitalize); } -PyDoc_STRVAR(casefold__doc__, - "S.casefold() -> str\n\ -\n\ -Return a version of S suitable for caseless comparisons."); - -static PyObject * -unicode_casefold(PyObject *self) +/*[clinic input] +str.casefold as unicode_casefold + +Return a version of S suitable for caseless comparisons. +[clinic start generated code]*/ + +static PyObject * +unicode_casefold_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=32efc19dfc5747cb input=a96f2b0d3daabd94]*/ { if (PyUnicode_READY(self) == -1) return NULL; @@ -10595,21 +10613,24 @@ return 1; } -PyDoc_STRVAR(center__doc__, - "S.center(width[, fillchar]) -> str\n\ -\n\ -Return S centered in a string of length width. Padding is\n\ -done using the specified fill character (default is a space)"); - -static PyObject * -unicode_center(PyObject *self, PyObject *args) +/*[clinic input] +str.center as unicode_center + + width: Py_ssize_t + fillchar: Py_UCS4(c_default="' '") = ' ' + / + +Return a centered string of length width. + +Padding is done using the specified fill character (default is a space). +[clinic start generated code]*/ + +static PyObject * +unicode_center_impl(PyUnicodeObject *self, Py_ssize_t width, + Py_UCS4 fillchar) +/*[clinic end generated code: output=2e7d0d5526909016 input=3217b0f8f795962b]*/ { Py_ssize_t marg, left; - Py_ssize_t width; - Py_UCS4 fillchar = ' '; - - if (!PyArg_ParseTuple(args, "n|O&:center", &width, convert_uc, &fillchar)) - return NULL; if (PyUnicode_READY(self) == -1) return NULL; @@ -11208,51 +11229,50 @@ return result; } -PyDoc_STRVAR(encode__doc__, - "S.encode(encoding='utf-8', errors='strict') -> bytes\n\ -\n\ -Encode S using the codec registered for encoding. Default encoding\n\ -is 'utf-8'. errors may be given to set a different error\n\ -handling scheme. Default is 'strict' meaning that encoding errors raise\n\ -a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n\ -'xmlcharrefreplace' as well as any other name registered with\n\ -codecs.register_error that can handle UnicodeEncodeErrors."); - -static PyObject * -unicode_encode(PyObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = {"encoding", "errors", 0}; - char *encoding = NULL; - char *errors = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:encode", - kwlist, &encoding, &errors)) - return NULL; +/*[clinic input] +str.encode as unicode_encode + + encoding: str(c_default="NULL") = 'utf-8' + The encoding in which to encode the string. + errors: str(c_default="NULL") = 'strict' + The error handling scheme to use for the handling of encoding errors. + The default is 'strict' meaning that encoding errors raise a + UnicodeEncodeError. Other possible values are 'ignore', 'replace' and + 'xmlcharrefreplace' as well as any other name registered with + codecs.register_error that can handle UnicodeEncodeErrors. + +Encode a string using the codec registered for encoding. +[clinic start generated code]*/ + +static PyObject * +unicode_encode_impl(PyUnicodeObject *self, const char *encoding, + const char *errors) +/*[clinic end generated code: output=7c8ee32d0c97d3e4 input=fbeaac578732fcb4]*/ +{ return PyUnicode_AsEncodedString(self, encoding, errors); } -PyDoc_STRVAR(expandtabs__doc__, - "S.expandtabs(tabsize=8) -> str\n\ -\n\ -Return a copy of S where all tab characters are expanded using spaces.\n\ -If tabsize is not given, a tab size of 8 characters is assumed."); - -static PyObject* -unicode_expandtabs(PyObject *self, PyObject *args, PyObject *kwds) +/*[clinic input] +str.expandtabs as unicode_expandtabs + + tabsize: int = 8 + +Return a copy where all tab characters are expanded using spaces. + +If tabsize is not given, a tab size of 8 characters is assumed. +[clinic start generated code]*/ + +static PyObject * +unicode_expandtabs_impl(PyUnicodeObject *self, int tabsize) +/*[clinic end generated code: output=7b9a8e32612b74a2 input=8a01914034af4c85]*/ { Py_ssize_t i, j, line_pos, src_len, incr; Py_UCS4 ch; PyObject *u; void *src_data, *dest_data; - static char *kwlist[] = {"tabsize", 0}; - int tabsize = 8; int kind; int found; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:expandtabs", - kwlist, &tabsize)) - return NULL; - if (PyUnicode_READY(self) == -1) return NULL; @@ -11454,14 +11474,18 @@ return PyLong_FromSsize_t(result); } -PyDoc_STRVAR(islower__doc__, - "S.islower() -> bool\n\ -\n\ -Return True if all cased characters in S are lowercase and there is\n\ -at least one cased character in S, False otherwise."); - -static PyObject* -unicode_islower(PyObject *self) +/*[clinic input] +str.islower as unicode_islower + +Return whether the string is a lowercase string; False otherwise. + +A string is lowercase if all cased characters in the string are lowercase and +there is at least one cased character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_islower_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=4af568dcf461a46d input=46eeb20d935af050]*/ { Py_ssize_t i, length; int kind; @@ -11495,14 +11519,18 @@ return PyBool_FromLong(cased); } -PyDoc_STRVAR(isupper__doc__, - "S.isupper() -> bool\n\ -\n\ -Return True if all cased characters in S are uppercase and there is\n\ -at least one cased character in S, False otherwise."); - -static PyObject* -unicode_isupper(PyObject *self) +/*[clinic input] +str.isupper as unicode_isupper + +Return True if the string is an uppercase string; False otherwise. + +A string is uppercase if all cased characters in the string are uppercase and +there is at least one cased character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_isupper_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=cc33db6b32247b2a input=dd0a595fc871eee0]*/ { Py_ssize_t i, length; int kind; @@ -11536,16 +11564,18 @@ return PyBool_FromLong(cased); } -PyDoc_STRVAR(istitle__doc__, - "S.istitle() -> bool\n\ -\n\ -Return True if S is a titlecased string and there is at least one\n\ -character in S, i.e. upper- and titlecase characters may only\n\ -follow uncased characters and lowercase characters only cased ones.\n\ -Return False otherwise."); - -static PyObject* -unicode_istitle(PyObject *self) +/*[clinic input] +str.istitle as unicode_istitle + +Return True if the string is a title-cased string; False otherwise. + +In a title-cased string, upper- and title-case characters may only +follow uncased characters and lowercase characters only cased ones. +[clinic start generated code]*/ + +static PyObject * +unicode_istitle_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=e6ced078dcc13741 input=2c56883d113d644d]*/ { Py_ssize_t i, length; int kind; @@ -11592,14 +11622,18 @@ return PyBool_FromLong(cased); } -PyDoc_STRVAR(isspace__doc__, - "S.isspace() -> bool\n\ -\n\ -Return True if all characters in S are whitespace\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isspace(PyObject *self) +/*[clinic input] +str.isspace as unicode_isspace + +Return True if the string is a whitespace string; False otherwise. + +A string is whitespace if all characters in the string are whitespace and there +is at least one character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_isspace_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=8f3861b5b22f8e57 input=b9506a23e312d203]*/ { Py_ssize_t i, length; int kind; @@ -11628,14 +11662,18 @@ return PyBool_FromLong(1); } -PyDoc_STRVAR(isalpha__doc__, - "S.isalpha() -> bool\n\ -\n\ -Return True if all characters in S are alphabetic\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isalpha(PyObject *self) +/*[clinic input] +str.isalpha as unicode_isalpha + +Return True if the string is an alphabetic string; False otherwise. + +A string is alphabetic if all characters in the string are alphabetic and there +is at least one character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_isalpha_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=614a2ab09ac3ea17 input=17e3788814472079]*/ { Py_ssize_t i, length; int kind; @@ -11663,14 +11701,18 @@ return PyBool_FromLong(1); } -PyDoc_STRVAR(isalnum__doc__, - "S.isalnum() -> bool\n\ -\n\ -Return True if all characters in S are alphanumeric\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isalnum(PyObject *self) +/*[clinic input] +str.isalnum as unicode_isalnum + +Return True if the string is an alpha-numeric string; False otherwise. + +A string is alpha-numeric if all characters in the string are alpha-numeric and +there is at least one character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_isalnum_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=e79c73477958e816 input=d350c4f7c59b4758]*/ { int kind; void *data; @@ -11701,14 +11743,18 @@ return PyBool_FromLong(1); } -PyDoc_STRVAR(isdecimal__doc__, - "S.isdecimal() -> bool\n\ -\n\ -Return True if there are only decimal characters in S,\n\ -False otherwise."); - -static PyObject* -unicode_isdecimal(PyObject *self) +/*[clinic input] +str.isdecimal as unicode_isdecimal + +Return True if the string is a decimal string; False otherwise. + +A string is a digit string if all characters in the string are decimal and +there is at least one character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_isdecimal_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=50e16c9a8be4f9bb input=40536fb80e5f1dc1]*/ { Py_ssize_t i, length; int kind; @@ -11736,14 +11782,18 @@ return PyBool_FromLong(1); } -PyDoc_STRVAR(isdigit__doc__, - "S.isdigit() -> bool\n\ -\n\ -Return True if all characters in S are digits\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isdigit(PyObject *self) +/*[clinic input] +str.isdigit as unicode_isdigit + +Return True if the string is a digit string; False otherwise. + +A string is a digit string if all characters in the string are digits and there +is at least one character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_isdigit_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=e41337ed454c6e91 input=c6a222be1aaec2af]*/ { Py_ssize_t i, length; int kind; @@ -11772,14 +11822,18 @@ return PyBool_FromLong(1); } -PyDoc_STRVAR(isnumeric__doc__, - "S.isnumeric() -> bool\n\ -\n\ -Return True if there are only numeric characters in S,\n\ -False otherwise."); - -static PyObject* -unicode_isnumeric(PyObject *self) +/*[clinic input] +str.isnumeric as unicode_isnumeric + +Return True if the string is an numeric string; False otherwise. + +A string is numeric if all characters in the string are numeric and there is at +least one character in the string. +[clinic start generated code]*/ + +static PyObject * +unicode_isnumeric_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=7889781a34780c5f input=e3b37b2cc8854f35]*/ { Py_ssize_t i, length; int kind; @@ -11844,29 +11898,34 @@ return 1; } -PyDoc_STRVAR(isidentifier__doc__, - "S.isidentifier() -> bool\n\ -\n\ -Return True if S is a valid identifier according\n\ -to the language definition.\n\ -\n\ -Use keyword.iskeyword() to test for reserved identifiers\n\ -such as \"def\" and \"class\".\n"); - -static PyObject* -unicode_isidentifier(PyObject *self) +/*[clinic input] +str.isidentifier as unicode_isidentifier + +Return True if the string is a valid Python identifier; False otherwise. + +Use keyword.iskeyword() to test for reserved identifiers such as "def" and +"class". +[clinic start generated code]*/ + +static PyObject * +unicode_isidentifier_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=e424ab81d70ed5dc input=95eebe40d6d91234]*/ { return PyBool_FromLong(PyUnicode_IsIdentifier(self)); } -PyDoc_STRVAR(isprintable__doc__, - "S.isprintable() -> bool\n\ -\n\ -Return True if all characters in S are considered\n\ -printable in repr() or S is empty, False otherwise."); - -static PyObject* -unicode_isprintable(PyObject *self) +/*[clinic input] +str.isprintable as unicode_isprintable + +Return True if the string is printable; False otherwise. + +A string is printable if all of its characters are considered printable in +repr() or if it is empty. +[clinic start generated code]*/ + +static PyObject * +unicode_isprintable_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=c2ffad6af8606b26 input=20c53134171af84e]*/ { Py_ssize_t i, length; int kind; @@ -11891,16 +11950,27 @@ Py_RETURN_TRUE; } -PyDoc_STRVAR(join__doc__, - "S.join(iterable) -> str\n\ -\n\ -Return a string which is the concatenation of the strings in the\n\ -iterable. The separator between elements is S."); - -static PyObject* -unicode_join(PyObject *self, PyObject *data) -{ - return PyUnicode_Join(self, data); +/*[clinic input] +str.join as unicode_join + + iterable: object + / + +Concatenate any number of strings. + +The string whose method is called is inserted in between each pair of given +strings. + +The result is returned as a new string. + +Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs' +[clinic start generated code]*/ + +static PyObject * +unicode_join(PyUnicodeObject *self, PyObject *iterable) +/*[clinic end generated code: output=13b8465c2d1e4b95 input=465f62626109db6b]*/ +{ + return PyUnicode_Join(self, iterable); } static Py_ssize_t @@ -11911,21 +11981,22 @@ return PyUnicode_GET_LENGTH(self); } -PyDoc_STRVAR(ljust__doc__, - "S.ljust(width[, fillchar]) -> str\n\ -\n\ -Return S left-justified in a Unicode string of length width. Padding is\n\ -done using the specified fill character (default is a space)."); - -static PyObject * -unicode_ljust(PyObject *self, PyObject *args) -{ - Py_ssize_t width; - Py_UCS4 fillchar = ' '; - - if (!PyArg_ParseTuple(args, "n|O&:ljust", &width, convert_uc, &fillchar)) - return NULL; - +/*[clinic input] +str.ljust as unicode_ljust + + width: Py_ssize_t + fillchar: Py_UCS4(c_default="' '") = ' ' + / + +Return a left-justified string of length width. + +Padding is done using the specified fill character (default is a space). +[clinic start generated code]*/ + +static PyObject * +unicode_ljust_impl(PyUnicodeObject *self, Py_ssize_t width, Py_UCS4 fillchar) +/*[clinic end generated code: output=6e4d59fd1335aedc input=cf782488ee87e3a3]*/ +{ if (PyUnicode_READY(self) == -1) return NULL; @@ -11935,13 +12006,15 @@ return pad(self, 0, width - PyUnicode_GET_LENGTH(self), fillchar); } -PyDoc_STRVAR(lower__doc__, - "S.lower() -> str\n\ -\n\ -Return a copy of the string S converted to lowercase."); - -static PyObject* -unicode_lower(PyObject *self) +/*[clinic input] +str.lower as unicode_lower + +Return a copy of the string converted to lowercase. +[clinic start generated code]*/ + +static PyObject * +unicode_lower_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=ff8740b0c9044b56 input=60a2984b8beff23a]*/ { if (PyUnicode_READY(self) == -1) return NULL; @@ -11955,9 +12028,9 @@ #define BOTHSTRIP 2 /* Arrays indexed by above */ -static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"}; - -#define STRIPNAME(i) (stripformat[i]+3) +static const char *stripfuncnames[] = {"lstrip", "rstrip", "strip"}; + +#define STRIPNAME(i) (stripfuncnames[i]) /* externally visible for str.strip(unicode) */ PyObject * @@ -12114,13 +12187,8 @@ static PyObject * -do_argstrip(PyObject *self, int striptype, PyObject *args) -{ - PyObject *sep = NULL; - - if (!PyArg_ParseTuple(args, stripformat[striptype], &sep)) - return NULL; - +do_argstrip(PyObject *self, int striptype, PyObject *sep) +{ if (sep != NULL && sep != Py_None) { if (PyUnicode_Check(sep)) return _PyUnicode_XStrip(self, striptype, sep); @@ -12136,52 +12204,60 @@ } -PyDoc_STRVAR(strip__doc__, - "S.strip([chars]) -> str\n\ -\n\ -Return a copy of the string S with leading and trailing\n\ -whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead."); - -static PyObject * -unicode_strip(PyObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, BOTHSTRIP); /* Common case */ - else - return do_argstrip(self, BOTHSTRIP, args); -} - - -PyDoc_STRVAR(lstrip__doc__, - "S.lstrip([chars]) -> str\n\ -\n\ -Return a copy of the string S with leading whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead."); - -static PyObject * -unicode_lstrip(PyObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, LEFTSTRIP); /* Common case */ - else - return do_argstrip(self, LEFTSTRIP, args); -} - - -PyDoc_STRVAR(rstrip__doc__, - "S.rstrip([chars]) -> str\n\ -\n\ -Return a copy of the string S with trailing whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead."); - -static PyObject * -unicode_rstrip(PyObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, RIGHTSTRIP); /* Common case */ - else - return do_argstrip(self, RIGHTSTRIP, args); +/*[clinic input] +str.strip as unicode_strip + + chars: object = NULL + / + +Return a copy of the string with leading and trailing whitespace removed. + +If chars is given and not None, remove characters in chars instead. +[clinic start generated code]*/ + +static PyObject * +unicode_strip_impl(PyUnicodeObject *self, PyObject *chars) +/*[clinic end generated code: output=0b8ba36ecd109f93 input=2de68e37ec5e6c3c]*/ +{ + return do_argstrip(self, BOTHSTRIP, chars); +} + + +/*[clinic input] +str.lstrip as unicode_lstrip + + chars: object = NULL + / + +Return a copy of the string with leading whitespace removed. + +If chars is given and not None, remove characters in chars instead. +[clinic start generated code]*/ + +static PyObject * +unicode_lstrip_impl(PyUnicodeObject *self, PyObject *chars) +/*[clinic end generated code: output=7744ab0028251585 input=9e56f3c45f5ff4c3]*/ +{ + return do_argstrip(self, LEFTSTRIP, chars); +} + + +/*[clinic input] +str.rstrip as unicode_rstrip + + chars: object = NULL + / + +Return a copy of the string with trailing whitespace removed. + +If chars is given and not None, remove characters in chars instead. +[clinic start generated code]*/ + +static PyObject * +unicode_rstrip_impl(PyUnicodeObject *self, PyObject *chars) +/*[clinic end generated code: output=f6cd8f5a314d6393 input=ac89d0219cb411ee]*/ +{ + return do_argstrip(self, RIGHTSTRIP, chars); } @@ -12286,40 +12362,46 @@ return result; } -PyDoc_STRVAR(replace__doc__, - "S.replace(old, new[, count]) -> str\n\ -\n\ -Return a copy of S with all occurrences of substring\n\ -old replaced by new. If the optional argument count is\n\ -given, only the first count occurrences are replaced."); - -static PyObject* -unicode_replace(PyObject *self, PyObject *args) -{ - PyObject *str1; - PyObject *str2; - Py_ssize_t maxcount = -1; +/*[clinic input] +str.replace as unicode_replace + + old: object + new: object + count: Py_ssize_t = -1 + Maximum number of occurrences to replace. + -1 (the default value) means replace all occurrences. + / + +Return a copy with all occurrences of substring old replaced by new. + +If the optional argument count is given, only the first count occurrences are +replaced. +[clinic start generated code]*/ + +static PyObject * +unicode_replace_impl(PyUnicodeObject *self, PyObject *old, PyObject *new, + Py_ssize_t count) +/*[clinic end generated code: output=33ebf0096616c0da input=39d12e26958f422a]*/ +{ PyObject *result; - if (!PyArg_ParseTuple(args, "OO|n:replace", &str1, &str2, &maxcount)) - return NULL; if (PyUnicode_READY(self) == -1) return NULL; - str1 = PyUnicode_FromObject(str1); - if (str1 == NULL) - return NULL; - str2 = PyUnicode_FromObject(str2); - if (str2 == NULL) { - Py_DECREF(str1); - return NULL; - } - if (PyUnicode_READY(str1) == -1 || PyUnicode_READY(str2) == -1) + old = PyUnicode_FromObject(old); + if (old == NULL) + return NULL; + new = PyUnicode_FromObject(new); + if (new == NULL) { + Py_DECREF(old); + return NULL; + } + if (PyUnicode_READY(old) == -1 || PyUnicode_READY(new) == -1) result = NULL; else - result = replace(self, str1, str2, maxcount); - - Py_DECREF(str1); - Py_DECREF(str2); + result = replace(self, old, new, count); + + Py_DECREF(old); + Py_DECREF(new); return result; } @@ -12570,21 +12652,22 @@ return PyLong_FromSsize_t(result); } -PyDoc_STRVAR(rjust__doc__, - "S.rjust(width[, fillchar]) -> str\n\ -\n\ -Return S right-justified in a string of length width. Padding is\n\ -done using the specified fill character (default is a space)."); - -static PyObject * -unicode_rjust(PyObject *self, PyObject *args) -{ - Py_ssize_t width; - Py_UCS4 fillchar = ' '; - - if (!PyArg_ParseTuple(args, "n|O&:rjust", &width, convert_uc, &fillchar)) - return NULL; - +/*[clinic input] +str.rjust as unicode_rjust + + width: Py_ssize_t + fillchar: Py_UCS4(c_default="' '") = ' ' + / + +Return a right-justified string of length width. + +Padding is done using the specified fill character (default is a space). +[clinic start generated code]*/ + +static PyObject * +unicode_rjust_impl(PyUnicodeObject *self, Py_ssize_t width, Py_UCS4 fillchar) +/*[clinic end generated code: output=ccf86242b5cf9811 input=3f80bc475603e920]*/ +{ if (PyUnicode_READY(self) == -1) return NULL; @@ -12617,32 +12700,30 @@ return result; } -PyDoc_STRVAR(split__doc__, - "S.split(sep=None, maxsplit=-1) -> list of strings\n\ -\n\ -Return a list of the words in S, using sep as the\n\ -delimiter string. If maxsplit is given, at most maxsplit\n\ -splits are done. If sep is not specified or is None, any\n\ -whitespace string is a separator and empty strings are\n\ -removed from the result."); - -static PyObject* -unicode_split(PyObject *self, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"sep", "maxsplit", 0}; - PyObject *substring = Py_None; - Py_ssize_t maxcount = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|On:split", - kwlist, &substring, &maxcount)) - return NULL; - - if (substring == Py_None) - return split(self, NULL, maxcount); - else if (PyUnicode_Check(substring)) - return split(self, substring, maxcount); +/*[clinic input] +str.split as unicode_split + + sep: object = None + The delimiter according which to split the string. + None (the default value) means split according to any whitespace, + and discard empty strings from the result. + maxsplit: Py_ssize_t = -1 + Maximum number of splits to do. + -1 (the default value) means no limit. + +Return a list of the words in the string, using sep as the delimiter string. +[clinic start generated code]*/ + +static PyObject * +unicode_split_impl(PyUnicodeObject *self, PyObject *sep, Py_ssize_t maxsplit) +/*[clinic end generated code: output=a3ba21da02ed374f input=606e750488a82359]*/ +{ + if (sep == Py_None) + return split(self, NULL, maxsplit); + else if (PyUnicode_Check(sep)) + return split(self, sep, maxsplit); else - return PyUnicode_Split(self, substring, maxcount); + return PyUnicode_Split(self, sep, maxsplit); } PyObject * @@ -12801,28 +12882,48 @@ return NULL; } -PyDoc_STRVAR(partition__doc__, - "S.partition(sep) -> (head, sep, tail)\n\ -\n\ -Search for the separator sep in S, and return the part before it,\n\ -the separator itself, and the part after it. If the separator is not\n\ -found, return S and two empty strings."); - -static PyObject* -unicode_partition(PyObject *self, PyObject *separator) +/*[clinic input] +str.partition as unicode_partition + + separator: object + / + +Partition the string into three parts using the given separator. + +This will search for the separator in the string. If the separator is found, +returns a 3-tuple containing the part before the separator, the separator +itself, and the part after it. + +If the separator is not found, returns a 3-tuple containing the original string +and two empty strings. +[clinic start generated code]*/ + +static PyObject * +unicode_partition(PyUnicodeObject *self, PyObject *separator) +/*[clinic end generated code: output=52fc09873e21f5dc input=24495f23d58e124e]*/ { return PyUnicode_Partition(self, separator); } -PyDoc_STRVAR(rpartition__doc__, - "S.rpartition(sep) -> (head, sep, tail)\n\ -\n\ -Search for the separator sep in S, starting at the end of S, and return\n\ -the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, return two empty strings and S."); - -static PyObject* -unicode_rpartition(PyObject *self, PyObject *separator) +/*[clinic input] +str.rpartition as unicode_rpartition + + separator: object + / + +Partition the string into three parts using the given separator. + +This will search for the separator in the string, starting and the end. If +the separator is found, returns a 3-tuple containing the part before the +separator, the separator itself, and the part after it. + +If the separator is not found, returns a 3-tuple containing two empty strings +and the original string. +[clinic start generated code]*/ + +static PyObject * +unicode_rpartition(PyUnicodeObject *self, PyObject *separator) +/*[clinic end generated code: output=d09ec453ab19f4b5 input=d29fb7396d2f22a9]*/ { return PyUnicode_RPartition(self, separator); } @@ -12850,51 +12951,42 @@ return result; } -PyDoc_STRVAR(rsplit__doc__, - "S.rsplit(sep=None, maxsplit=-1) -> list of strings\n\ -\n\ -Return a list of the words in S, using sep as the\n\ -delimiter string, starting at the end of the string and\n\ -working to the front. If maxsplit is given, at most maxsplit\n\ -splits are done. If sep is not specified, any whitespace string\n\ -is a separator."); - -static PyObject* -unicode_rsplit(PyObject *self, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"sep", "maxsplit", 0}; - PyObject *substring = Py_None; - Py_ssize_t maxcount = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|On:rsplit", - kwlist, &substring, &maxcount)) - return NULL; - - if (substring == Py_None) - return rsplit(self, NULL, maxcount); - else if (PyUnicode_Check(substring)) - return rsplit(self, substring, maxcount); +/*[clinic input] +str.rsplit as unicode_rsplit = str.split + +Return a list of the words in the string, using sep as the delimiter string. + +Splits are done starting at the end of the string and working to the front. +[clinic start generated code]*/ + +static PyObject * +unicode_rsplit_impl(PyUnicodeObject *self, PyObject *sep, + Py_ssize_t maxsplit) +/*[clinic end generated code: output=17d0c77f7ca97f35 input=12ad4bf57dd35f15]*/ +{ + if (sep == Py_None) + return rsplit(self, NULL, maxsplit); + else if (PyUnicode_Check(sep)) + return rsplit(self, sep, maxsplit); else - return PyUnicode_RSplit(self, substring, maxcount); -} - -PyDoc_STRVAR(splitlines__doc__, - "S.splitlines([keepends]) -> list of strings\n\ -\n\ -Return a list of the lines in S, breaking at line boundaries.\n\ -Line breaks are not included in the resulting list unless keepends\n\ -is given and true."); - -static PyObject* -unicode_splitlines(PyObject *self, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"keepends", 0}; - int keepends = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:splitlines", - kwlist, &keepends)) - return NULL; - + return PyUnicode_RSplit(self, sep, maxsplit); +} + +/*[clinic input] +str.splitlines as unicode_splitlines + + keepends: int(py_default="False") = 0 + +Return a list of the lines in the string, breaking at line boundaries. + +Line breaks are not included in the resulting list unless keepends is given and +true. +[clinic start generated code]*/ + +static PyObject * +unicode_splitlines_impl(PyUnicodeObject *self, int keepends) +/*[clinic end generated code: output=7b27faf63f66befc input=71b1992258559c8f]*/ +{ return PyUnicode_Splitlines(self, keepends); } @@ -12904,14 +12996,15 @@ return unicode_result_unchanged(self); } -PyDoc_STRVAR(swapcase__doc__, - "S.swapcase() -> str\n\ -\n\ -Return a copy of S with uppercase characters converted to lowercase\n\ -and vice versa."); - -static PyObject* -unicode_swapcase(PyObject *self) +/*[clinic input] +str.swapcase as unicode_swapcase + +Convert uppercase characters to lowercase and lowercase characters to uppercase. +[clinic start generated code]*/ + +static PyObject * +unicode_swapcase_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=4cca20a157b02082 input=3f3ef96d5798a7bb]*/ { if (PyUnicode_READY(self) == -1) return NULL; @@ -13048,28 +13141,37 @@ return NULL; } -PyDoc_STRVAR(translate__doc__, - "S.translate(table) -> str\n\ -\n\ -Return a copy of the string S, where all characters have been mapped\n\ -through the given translation table, which must be a mapping of\n\ -Unicode ordinals to Unicode ordinals, strings, or None.\n\ -Unmapped characters are left untouched. Characters mapped to None\n\ -are deleted."); - -static PyObject* -unicode_translate(PyObject *self, PyObject *table) +/*[clinic input] +str.translate as unicode_translate + + table: object + Translation table, which must be a mapping of Unicode ordinals to + Unicode ordinals, strings, or None. + / + +Replace each character in the string using the given translation table. + +Characters not in the translation table are left untouched. + +Characters mapped to None are deleted. +[clinic start generated code]*/ + +static PyObject * +unicode_translate(PyUnicodeObject *self, PyObject *table) +/*[clinic end generated code: output=2d6836cdabb65bdb input=8356ff539f5f2028]*/ { return _PyUnicode_TranslateCharmap(self, table, "ignore"); } -PyDoc_STRVAR(upper__doc__, - "S.upper() -> str\n\ -\n\ -Return a copy of S converted to uppercase."); - -static PyObject* -unicode_upper(PyObject *self) +/*[clinic input] +str.upper as unicode_upper + +Return a copy of the string converted to uppercase. +[clinic start generated code]*/ + +static PyObject * +unicode_upper_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=b7b3eaa31f5dbd4d input=db3d55682dfe2e6c]*/ { if (PyUnicode_READY(self) == -1) return NULL; @@ -13078,25 +13180,27 @@ return case_operation(self, do_upper); } -PyDoc_STRVAR(zfill__doc__, - "S.zfill(width) -> str\n\ -\n\ -Pad a numeric string S with zeros on the left, to fill a field\n\ -of the specified width. The string S is never truncated."); - -static PyObject * -unicode_zfill(PyObject *self, PyObject *args) +/*[clinic input] +str.zfill as unicode_zfill + + width: Py_ssize_t + / + +Pad a numeric string with zeros on the left, to fill a field of the given width. + +The original string is never truncated. +[clinic start generated code]*/ + +static PyObject * +unicode_zfill_impl(PyUnicodeObject *self, Py_ssize_t width) +/*[clinic end generated code: output=39359bb274d2f5c1 input=3559257ab7bfed6e]*/ { Py_ssize_t fill; PyObject *u; - Py_ssize_t width; int kind; void *data; Py_UCS4 chr; - if (!PyArg_ParseTuple(args, "n:zfill", &width)) - return NULL; - if (PyUnicode_READY(self) == -1) return NULL; @@ -13546,16 +13650,22 @@ Return a formatted version of S, using substitutions from mapping.\n\ The substitutions are identified by braces ('{' and '}')."); -static PyObject * -unicode__format__(PyObject* self, PyObject* args) -{ - PyObject *format_spec; +/*[clinic input] +str.__format__ as unicode___format__ + + format_spec: unicode + / + +Return a formatted version of S as described by format_spec. +[clinic start generated code]*/ + +static PyObject * +unicode___format___impl(PyUnicodeObject *self, PyObject *format_spec) +/*[clinic end generated code: output=2d38a32fd52646cf input=1f0623ca7b7c5981]*/ +{ _PyUnicodeWriter writer; int ret; - if (!PyArg_ParseTuple(args, "U:__format__", &format_spec)) - return NULL; - if (PyUnicode_READY(self) == -1) return NULL; _PyUnicodeWriter_Init(&writer); @@ -13569,44 +13679,43 @@ return _PyUnicodeWriter_Finish(&writer); } -PyDoc_STRVAR(p_format__doc__, - "S.__format__(format_spec) -> str\n\ -\n\ -Return a formatted version of S as described by format_spec."); - -static PyObject * -unicode__sizeof__(PyObject *v) +/*[clinic input] +str.__sizeof__ as unicode_sizeof + +Return the size of the string in memory, in bytes. +[clinic start generated code]*/ + +static PyObject * +unicode_sizeof_impl(PyUnicodeObject *self) +/*[clinic end generated code: output=ec3fec640fb54c92 input=6dd011c108e33fb0]*/ { Py_ssize_t size; /* If it's a compact object, account for base structure + character data. */ - if (PyUnicode_IS_COMPACT_ASCII(v)) - size = sizeof(PyASCIIObject) + PyUnicode_GET_LENGTH(v) + 1; - else if (PyUnicode_IS_COMPACT(v)) + if (PyUnicode_IS_COMPACT_ASCII(self)) + size = sizeof(PyASCIIObject) + PyUnicode_GET_LENGTH(self) + 1; + else if (PyUnicode_IS_COMPACT(self)) size = sizeof(PyCompactUnicodeObject) + - (PyUnicode_GET_LENGTH(v) + 1) * PyUnicode_KIND(v); + (PyUnicode_GET_LENGTH(self) + 1) * PyUnicode_KIND(self); else { /* If it is a two-block object, account for base object, and for character block if present. */ size = sizeof(PyUnicodeObject); - if (_PyUnicode_DATA_ANY(v)) - size += (PyUnicode_GET_LENGTH(v) + 1) * - PyUnicode_KIND(v); + if (_PyUnicode_DATA_ANY(self)) + size += (PyUnicode_GET_LENGTH(self) + 1) * + PyUnicode_KIND(self); } /* If the wstr pointer is present, account for it unless it is shared with the data pointer. Check if the data is not shared. */ - if (_PyUnicode_HAS_WSTR_MEMORY(v)) - size += (PyUnicode_WSTR_LENGTH(v) + 1) * sizeof(wchar_t); - if (_PyUnicode_HAS_UTF8_MEMORY(v)) - size += PyUnicode_UTF8_LENGTH(v) + 1; + if (_PyUnicode_HAS_WSTR_MEMORY(self)) + size += (PyUnicode_WSTR_LENGTH(self) + 1) * sizeof(wchar_t); + if (_PyUnicode_HAS_UTF8_MEMORY(self)) + size += PyUnicode_UTF8_LENGTH(self) + 1; return PyLong_FromSsize_t(size); } -PyDoc_STRVAR(sizeof__doc__, - "S.__sizeof__() -> size of S in memory, in bytes"); - static PyObject * unicode_getnewargs(PyObject *v) { @@ -13617,54 +13726,52 @@ } static PyMethodDef unicode_methods[] = { - {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encode__doc__}, - {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__}, - {"split", (PyCFunction) unicode_split, METH_VARARGS | METH_KEYWORDS, split__doc__}, - {"rsplit", (PyCFunction) unicode_rsplit, METH_VARARGS | METH_KEYWORDS, rsplit__doc__}, - {"join", (PyCFunction) unicode_join, METH_O, join__doc__}, - {"capitalize", (PyCFunction) unicode_capitalize, METH_NOARGS, capitalize__doc__}, - {"casefold", (PyCFunction) unicode_casefold, METH_NOARGS, casefold__doc__}, - {"title", (PyCFunction) unicode_title, METH_NOARGS, title__doc__}, - {"center", (PyCFunction) unicode_center, METH_VARARGS, center__doc__}, + UNICODE_ENCODE_METHODDEF + UNICODE_REPLACE_METHODDEF + UNICODE_SPLIT_METHODDEF + UNICODE_RSPLIT_METHODDEF + UNICODE_JOIN_METHODDEF + UNICODE_CAPITALIZE_METHODDEF + UNICODE_CASEFOLD_METHODDEF + UNICODE_TITLE_METHODDEF + UNICODE_CENTER_METHODDEF {"count", (PyCFunction) unicode_count, METH_VARARGS, count__doc__}, - {"expandtabs", (PyCFunction) unicode_expandtabs, - METH_VARARGS | METH_KEYWORDS, expandtabs__doc__}, + UNICODE_EXPANDTABS_METHODDEF {"find", (PyCFunction) unicode_find, METH_VARARGS, find__doc__}, - {"partition", (PyCFunction) unicode_partition, METH_O, partition__doc__}, + UNICODE_PARTITION_METHODDEF {"index", (PyCFunction) unicode_index, METH_VARARGS, index__doc__}, - {"ljust", (PyCFunction) unicode_ljust, METH_VARARGS, ljust__doc__}, - {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, - {"lstrip", (PyCFunction) unicode_lstrip, METH_VARARGS, lstrip__doc__}, + UNICODE_LJUST_METHODDEF + UNICODE_LOWER_METHODDEF + UNICODE_LSTRIP_METHODDEF {"rfind", (PyCFunction) unicode_rfind, METH_VARARGS, rfind__doc__}, {"rindex", (PyCFunction) unicode_rindex, METH_VARARGS, rindex__doc__}, - {"rjust", (PyCFunction) unicode_rjust, METH_VARARGS, rjust__doc__}, - {"rstrip", (PyCFunction) unicode_rstrip, METH_VARARGS, rstrip__doc__}, - {"rpartition", (PyCFunction) unicode_rpartition, METH_O, rpartition__doc__}, - {"splitlines", (PyCFunction) unicode_splitlines, - METH_VARARGS | METH_KEYWORDS, splitlines__doc__}, - {"strip", (PyCFunction) unicode_strip, METH_VARARGS, strip__doc__}, - {"swapcase", (PyCFunction) unicode_swapcase, METH_NOARGS, swapcase__doc__}, - {"translate", (PyCFunction) unicode_translate, METH_O, translate__doc__}, - {"upper", (PyCFunction) unicode_upper, METH_NOARGS, upper__doc__}, + UNICODE_RJUST_METHODDEF + UNICODE_RSTRIP_METHODDEF + UNICODE_RPARTITION_METHODDEF + UNICODE_SPLITLINES_METHODDEF + UNICODE_STRIP_METHODDEF + UNICODE_SWAPCASE_METHODDEF + UNICODE_TRANSLATE_METHODDEF + UNICODE_UPPER_METHODDEF {"startswith", (PyCFunction) unicode_startswith, METH_VARARGS, startswith__doc__}, {"endswith", (PyCFunction) unicode_endswith, METH_VARARGS, endswith__doc__}, - {"islower", (PyCFunction) unicode_islower, METH_NOARGS, islower__doc__}, - {"isupper", (PyCFunction) unicode_isupper, METH_NOARGS, isupper__doc__}, - {"istitle", (PyCFunction) unicode_istitle, METH_NOARGS, istitle__doc__}, - {"isspace", (PyCFunction) unicode_isspace, METH_NOARGS, isspace__doc__}, - {"isdecimal", (PyCFunction) unicode_isdecimal, METH_NOARGS, isdecimal__doc__}, - {"isdigit", (PyCFunction) unicode_isdigit, METH_NOARGS, isdigit__doc__}, - {"isnumeric", (PyCFunction) unicode_isnumeric, METH_NOARGS, isnumeric__doc__}, - {"isalpha", (PyCFunction) unicode_isalpha, METH_NOARGS, isalpha__doc__}, - {"isalnum", (PyCFunction) unicode_isalnum, METH_NOARGS, isalnum__doc__}, - {"isidentifier", (PyCFunction) unicode_isidentifier, METH_NOARGS, isidentifier__doc__}, - {"isprintable", (PyCFunction) unicode_isprintable, METH_NOARGS, isprintable__doc__}, - {"zfill", (PyCFunction) unicode_zfill, METH_VARARGS, zfill__doc__}, + UNICODE_ISLOWER_METHODDEF + UNICODE_ISUPPER_METHODDEF + UNICODE_ISTITLE_METHODDEF + UNICODE_ISSPACE_METHODDEF + UNICODE_ISDECIMAL_METHODDEF + UNICODE_ISDIGIT_METHODDEF + UNICODE_ISNUMERIC_METHODDEF + UNICODE_ISALPHA_METHODDEF + UNICODE_ISALNUM_METHODDEF + UNICODE_ISIDENTIFIER_METHODDEF + UNICODE_ISPRINTABLE_METHODDEF + UNICODE_ZFILL_METHODDEF {"format", (PyCFunction) do_string_format, METH_VARARGS | METH_KEYWORDS, format__doc__}, {"format_map", (PyCFunction) do_string_format_map, METH_O, format_map__doc__}, - {"__format__", (PyCFunction) unicode__format__, METH_VARARGS, p_format__doc__}, + UNICODE___FORMAT___METHODDEF UNICODE_MAKETRANS_METHODDEF - {"__sizeof__", (PyCFunction) unicode__sizeof__, METH_NOARGS, sizeof__doc__}, + UNICODE_SIZEOF_METHODDEF #if 0 /* These methods are just used for debugging the implementation. */ {"_decimal2ascii", (PyCFunction) unicode__decimal2ascii, METH_NOARGS},