LCOV - code coverage report
Current view: top level - Objects/clinic - unicodeobject.c.h (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 364 403 90.3 %
Date: 2022-07-07 18:19:46 Functions: 37 38 97.4 %

          Line data    Source code
       1             : /*[clinic input]
       2             : preserve
       3             : [clinic start generated code]*/
       4             : 
       5             : PyDoc_STRVAR(EncodingMap_size__doc__,
       6             : "size($self, /)\n"
       7             : "--\n"
       8             : "\n"
       9             : "Return the size (in bytes) of this object.");
      10             : 
      11             : #define ENCODINGMAP_SIZE_METHODDEF    \
      12             :     {"size", (PyCFunction)EncodingMap_size, METH_NOARGS, EncodingMap_size__doc__},
      13             : 
      14             : static PyObject *
      15             : EncodingMap_size_impl(struct encoding_map *self);
      16             : 
      17             : static PyObject *
      18           0 : EncodingMap_size(struct encoding_map *self, PyObject *Py_UNUSED(ignored))
      19             : {
      20           0 :     return EncodingMap_size_impl(self);
      21             : }
      22             : 
      23             : PyDoc_STRVAR(unicode_title__doc__,
      24             : "title($self, /)\n"
      25             : "--\n"
      26             : "\n"
      27             : "Return a version of the string where each word is titlecased.\n"
      28             : "\n"
      29             : "More specifically, words start with uppercased characters and all remaining\n"
      30             : "cased characters have lower case.");
      31             : 
      32             : #define UNICODE_TITLE_METHODDEF    \
      33             :     {"title", (PyCFunction)unicode_title, METH_NOARGS, unicode_title__doc__},
      34             : 
      35             : static PyObject *
      36             : unicode_title_impl(PyObject *self);
      37             : 
      38             : static PyObject *
      39     4458370 : unicode_title(PyObject *self, PyObject *Py_UNUSED(ignored))
      40             : {
      41     4458370 :     return unicode_title_impl(self);
      42             : }
      43             : 
      44             : PyDoc_STRVAR(unicode_capitalize__doc__,
      45             : "capitalize($self, /)\n"
      46             : "--\n"
      47             : "\n"
      48             : "Return a capitalized version of the string.\n"
      49             : "\n"
      50             : "More specifically, make the first character have upper case and the rest lower\n"
      51             : "case.");
      52             : 
      53             : #define UNICODE_CAPITALIZE_METHODDEF    \
      54             :     {"capitalize", (PyCFunction)unicode_capitalize, METH_NOARGS, unicode_capitalize__doc__},
      55             : 
      56             : static PyObject *
      57             : unicode_capitalize_impl(PyObject *self);
      58             : 
      59             : static PyObject *
      60       24227 : unicode_capitalize(PyObject *self, PyObject *Py_UNUSED(ignored))
      61             : {
      62       24227 :     return unicode_capitalize_impl(self);
      63             : }
      64             : 
      65             : PyDoc_STRVAR(unicode_casefold__doc__,
      66             : "casefold($self, /)\n"
      67             : "--\n"
      68             : "\n"
      69             : "Return a version of the string suitable for caseless comparisons.");
      70             : 
      71             : #define UNICODE_CASEFOLD_METHODDEF    \
      72             :     {"casefold", (PyCFunction)unicode_casefold, METH_NOARGS, unicode_casefold__doc__},
      73             : 
      74             : static PyObject *
      75             : unicode_casefold_impl(PyObject *self);
      76             : 
      77             : static PyObject *
      78         700 : unicode_casefold(PyObject *self, PyObject *Py_UNUSED(ignored))
      79             : {
      80         700 :     return unicode_casefold_impl(self);
      81             : }
      82             : 
      83             : PyDoc_STRVAR(unicode_center__doc__,
      84             : "center($self, width, fillchar=\' \', /)\n"
      85             : "--\n"
      86             : "\n"
      87             : "Return a centered string of length width.\n"
      88             : "\n"
      89             : "Padding is done using the specified fill character (default is a space).");
      90             : 
      91             : #define UNICODE_CENTER_METHODDEF    \
      92             :     {"center", _PyCFunction_CAST(unicode_center), METH_FASTCALL, unicode_center__doc__},
      93             : 
      94             : static PyObject *
      95             : unicode_center_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar);
      96             : 
      97             : static PyObject *
      98        7864 : unicode_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
      99             : {
     100        7864 :     PyObject *return_value = NULL;
     101             :     Py_ssize_t width;
     102        7864 :     Py_UCS4 fillchar = ' ';
     103             : 
     104        7864 :     if (!_PyArg_CheckPositional("center", nargs, 1, 2)) {
     105           1 :         goto exit;
     106             :     }
     107             :     {
     108        7863 :         Py_ssize_t ival = -1;
     109        7863 :         PyObject *iobj = _PyNumber_Index(args[0]);
     110        7863 :         if (iobj != NULL) {
     111        7863 :             ival = PyLong_AsSsize_t(iobj);
     112        7863 :             Py_DECREF(iobj);
     113             :         }
     114        7863 :         if (ival == -1 && PyErr_Occurred()) {
     115           0 :             goto exit;
     116             :         }
     117        7863 :         width = ival;
     118             :     }
     119        7863 :     if (nargs < 2) {
     120        7857 :         goto skip_optional;
     121             :     }
     122           6 :     if (!convert_uc(args[1], &fillchar)) {
     123           0 :         goto exit;
     124             :     }
     125           6 : skip_optional:
     126        7863 :     return_value = unicode_center_impl(self, width, fillchar);
     127             : 
     128        7864 : exit:
     129        7864 :     return return_value;
     130             : }
     131             : 
     132             : PyDoc_STRVAR(unicode_encode__doc__,
     133             : "encode($self, /, encoding=\'utf-8\', errors=\'strict\')\n"
     134             : "--\n"
     135             : "\n"
     136             : "Encode the string using the codec registered for encoding.\n"
     137             : "\n"
     138             : "  encoding\n"
     139             : "    The encoding in which to encode the string.\n"
     140             : "  errors\n"
     141             : "    The error handling scheme to use for encoding errors.\n"
     142             : "    The default is \'strict\' meaning that encoding errors raise a\n"
     143             : "    UnicodeEncodeError.  Other possible values are \'ignore\', \'replace\' and\n"
     144             : "    \'xmlcharrefreplace\' as well as any other name registered with\n"
     145             : "    codecs.register_error that can handle UnicodeEncodeErrors.");
     146             : 
     147             : #define UNICODE_ENCODE_METHODDEF    \
     148             :     {"encode", _PyCFunction_CAST(unicode_encode), METH_FASTCALL|METH_KEYWORDS, unicode_encode__doc__},
     149             : 
     150             : static PyObject *
     151             : unicode_encode_impl(PyObject *self, const char *encoding, const char *errors);
     152             : 
     153             : static PyObject *
     154     5307600 : unicode_encode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     155             : {
     156     5307600 :     PyObject *return_value = NULL;
     157             :     static const char * const _keywords[] = {"encoding", "errors", NULL};
     158             :     static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0};
     159             :     PyObject *argsbuf[2];
     160     5307600 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     161     5307600 :     const char *encoding = NULL;
     162     5307600 :     const char *errors = NULL;
     163             : 
     164     5307600 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
     165     5307600 :     if (!args) {
     166           1 :         goto exit;
     167             :     }
     168     5307600 :     if (!noptargs) {
     169       93534 :         goto skip_optional_pos;
     170             :     }
     171     5214060 :     if (args[0]) {
     172     5214060 :         if (!PyUnicode_Check(args[0])) {
     173           0 :             _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[0]);
     174           0 :             goto exit;
     175             :         }
     176             :         Py_ssize_t encoding_length;
     177     5214060 :         encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length);
     178     5214060 :         if (encoding == NULL) {
     179           0 :             goto exit;
     180             :         }
     181     5214060 :         if (strlen(encoding) != (size_t)encoding_length) {
     182           0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
     183           0 :             goto exit;
     184             :         }
     185     5214060 :         if (!--noptargs) {
     186     1729140 :             goto skip_optional_pos;
     187             :         }
     188             :     }
     189     3484920 :     if (!PyUnicode_Check(args[1])) {
     190           0 :         _PyArg_BadArgument("encode", "argument 'errors'", "str", args[1]);
     191           0 :         goto exit;
     192             :     }
     193             :     Py_ssize_t errors_length;
     194     3484920 :     errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
     195     3484920 :     if (errors == NULL) {
     196           0 :         goto exit;
     197             :     }
     198     3484920 :     if (strlen(errors) != (size_t)errors_length) {
     199           0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     200           0 :         goto exit;
     201             :     }
     202     3484920 : skip_optional_pos:
     203     5307600 :     return_value = unicode_encode_impl(self, encoding, errors);
     204             : 
     205     5307600 : exit:
     206     5307600 :     return return_value;
     207             : }
     208             : 
     209             : PyDoc_STRVAR(unicode_expandtabs__doc__,
     210             : "expandtabs($self, /, tabsize=8)\n"
     211             : "--\n"
     212             : "\n"
     213             : "Return a copy where all tab characters are expanded using spaces.\n"
     214             : "\n"
     215             : "If tabsize is not given, a tab size of 8 characters is assumed.");
     216             : 
     217             : #define UNICODE_EXPANDTABS_METHODDEF    \
     218             :     {"expandtabs", _PyCFunction_CAST(unicode_expandtabs), METH_FASTCALL|METH_KEYWORDS, unicode_expandtabs__doc__},
     219             : 
     220             : static PyObject *
     221             : unicode_expandtabs_impl(PyObject *self, int tabsize);
     222             : 
     223             : static PyObject *
     224       56852 : unicode_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     225             : {
     226       56852 :     PyObject *return_value = NULL;
     227             :     static const char * const _keywords[] = {"tabsize", NULL};
     228             :     static _PyArg_Parser _parser = {NULL, _keywords, "expandtabs", 0};
     229             :     PyObject *argsbuf[1];
     230       56852 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     231       56852 :     int tabsize = 8;
     232             : 
     233       56852 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     234       56852 :     if (!args) {
     235           1 :         goto exit;
     236             :     }
     237       56851 :     if (!noptargs) {
     238        7128 :         goto skip_optional_pos;
     239             :     }
     240       49723 :     tabsize = _PyLong_AsInt(args[0]);
     241       49723 :     if (tabsize == -1 && PyErr_Occurred()) {
     242           0 :         goto exit;
     243             :     }
     244       49723 : skip_optional_pos:
     245       56851 :     return_value = unicode_expandtabs_impl(self, tabsize);
     246             : 
     247       56852 : exit:
     248       56852 :     return return_value;
     249             : }
     250             : 
     251             : PyDoc_STRVAR(unicode_isascii__doc__,
     252             : "isascii($self, /)\n"
     253             : "--\n"
     254             : "\n"
     255             : "Return True if all characters in the string are ASCII, False otherwise.\n"
     256             : "\n"
     257             : "ASCII characters have code points in the range U+0000-U+007F.\n"
     258             : "Empty string is ASCII too.");
     259             : 
     260             : #define UNICODE_ISASCII_METHODDEF    \
     261             :     {"isascii", (PyCFunction)unicode_isascii, METH_NOARGS, unicode_isascii__doc__},
     262             : 
     263             : static PyObject *
     264             : unicode_isascii_impl(PyObject *self);
     265             : 
     266             : static PyObject *
     267       39854 : unicode_isascii(PyObject *self, PyObject *Py_UNUSED(ignored))
     268             : {
     269       39854 :     return unicode_isascii_impl(self);
     270             : }
     271             : 
     272             : PyDoc_STRVAR(unicode_islower__doc__,
     273             : "islower($self, /)\n"
     274             : "--\n"
     275             : "\n"
     276             : "Return True if the string is a lowercase string, False otherwise.\n"
     277             : "\n"
     278             : "A string is lowercase if all cased characters in the string are lowercase and\n"
     279             : "there is at least one cased character in the string.");
     280             : 
     281             : #define UNICODE_ISLOWER_METHODDEF    \
     282             :     {"islower", (PyCFunction)unicode_islower, METH_NOARGS, unicode_islower__doc__},
     283             : 
     284             : static PyObject *
     285             : unicode_islower_impl(PyObject *self);
     286             : 
     287             : static PyObject *
     288     2233430 : unicode_islower(PyObject *self, PyObject *Py_UNUSED(ignored))
     289             : {
     290     2233430 :     return unicode_islower_impl(self);
     291             : }
     292             : 
     293             : PyDoc_STRVAR(unicode_isupper__doc__,
     294             : "isupper($self, /)\n"
     295             : "--\n"
     296             : "\n"
     297             : "Return True if the string is an uppercase string, False otherwise.\n"
     298             : "\n"
     299             : "A string is uppercase if all cased characters in the string are uppercase and\n"
     300             : "there is at least one cased character in the string.");
     301             : 
     302             : #define UNICODE_ISUPPER_METHODDEF    \
     303             :     {"isupper", (PyCFunction)unicode_isupper, METH_NOARGS, unicode_isupper__doc__},
     304             : 
     305             : static PyObject *
     306             : unicode_isupper_impl(PyObject *self);
     307             : 
     308             : static PyObject *
     309     3595200 : unicode_isupper(PyObject *self, PyObject *Py_UNUSED(ignored))
     310             : {
     311     3595200 :     return unicode_isupper_impl(self);
     312             : }
     313             : 
     314             : PyDoc_STRVAR(unicode_istitle__doc__,
     315             : "istitle($self, /)\n"
     316             : "--\n"
     317             : "\n"
     318             : "Return True if the string is a title-cased string, False otherwise.\n"
     319             : "\n"
     320             : "In a title-cased string, upper- and title-case characters may only\n"
     321             : "follow uncased characters and lowercase characters only cased ones.");
     322             : 
     323             : #define UNICODE_ISTITLE_METHODDEF    \
     324             :     {"istitle", (PyCFunction)unicode_istitle, METH_NOARGS, unicode_istitle__doc__},
     325             : 
     326             : static PyObject *
     327             : unicode_istitle_impl(PyObject *self);
     328             : 
     329             : static PyObject *
     330     2228270 : unicode_istitle(PyObject *self, PyObject *Py_UNUSED(ignored))
     331             : {
     332     2228270 :     return unicode_istitle_impl(self);
     333             : }
     334             : 
     335             : PyDoc_STRVAR(unicode_isspace__doc__,
     336             : "isspace($self, /)\n"
     337             : "--\n"
     338             : "\n"
     339             : "Return True if the string is a whitespace string, False otherwise.\n"
     340             : "\n"
     341             : "A string is whitespace if all characters in the string are whitespace and there\n"
     342             : "is at least one character in the string.");
     343             : 
     344             : #define UNICODE_ISSPACE_METHODDEF    \
     345             :     {"isspace", (PyCFunction)unicode_isspace, METH_NOARGS, unicode_isspace__doc__},
     346             : 
     347             : static PyObject *
     348             : unicode_isspace_impl(PyObject *self);
     349             : 
     350             : static PyObject *
     351     3418290 : unicode_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))
     352             : {
     353     3418290 :     return unicode_isspace_impl(self);
     354             : }
     355             : 
     356             : PyDoc_STRVAR(unicode_isalpha__doc__,
     357             : "isalpha($self, /)\n"
     358             : "--\n"
     359             : "\n"
     360             : "Return True if the string is an alphabetic string, False otherwise.\n"
     361             : "\n"
     362             : "A string is alphabetic if all characters in the string are alphabetic and there\n"
     363             : "is at least one character in the string.");
     364             : 
     365             : #define UNICODE_ISALPHA_METHODDEF    \
     366             :     {"isalpha", (PyCFunction)unicode_isalpha, METH_NOARGS, unicode_isalpha__doc__},
     367             : 
     368             : static PyObject *
     369             : unicode_isalpha_impl(PyObject *self);
     370             : 
     371             : static PyObject *
     372     2274480 : unicode_isalpha(PyObject *self, PyObject *Py_UNUSED(ignored))
     373             : {
     374     2274480 :     return unicode_isalpha_impl(self);
     375             : }
     376             : 
     377             : PyDoc_STRVAR(unicode_isalnum__doc__,
     378             : "isalnum($self, /)\n"
     379             : "--\n"
     380             : "\n"
     381             : "Return True if the string is an alpha-numeric string, False otherwise.\n"
     382             : "\n"
     383             : "A string is alpha-numeric if all characters in the string are alpha-numeric and\n"
     384             : "there is at least one character in the string.");
     385             : 
     386             : #define UNICODE_ISALNUM_METHODDEF    \
     387             :     {"isalnum", (PyCFunction)unicode_isalnum, METH_NOARGS, unicode_isalnum__doc__},
     388             : 
     389             : static PyObject *
     390             : unicode_isalnum_impl(PyObject *self);
     391             : 
     392             : static PyObject *
     393     2271170 : unicode_isalnum(PyObject *self, PyObject *Py_UNUSED(ignored))
     394             : {
     395     2271170 :     return unicode_isalnum_impl(self);
     396             : }
     397             : 
     398             : PyDoc_STRVAR(unicode_isdecimal__doc__,
     399             : "isdecimal($self, /)\n"
     400             : "--\n"
     401             : "\n"
     402             : "Return True if the string is a decimal string, False otherwise.\n"
     403             : "\n"
     404             : "A string is a decimal string if all characters in the string are decimal and\n"
     405             : "there is at least one character in the string.");
     406             : 
     407             : #define UNICODE_ISDECIMAL_METHODDEF    \
     408             :     {"isdecimal", (PyCFunction)unicode_isdecimal, METH_NOARGS, unicode_isdecimal__doc__},
     409             : 
     410             : static PyObject *
     411             : unicode_isdecimal_impl(PyObject *self);
     412             : 
     413             : static PyObject *
     414     2228410 : unicode_isdecimal(PyObject *self, PyObject *Py_UNUSED(ignored))
     415             : {
     416     2228410 :     return unicode_isdecimal_impl(self);
     417             : }
     418             : 
     419             : PyDoc_STRVAR(unicode_isdigit__doc__,
     420             : "isdigit($self, /)\n"
     421             : "--\n"
     422             : "\n"
     423             : "Return True if the string is a digit string, False otherwise.\n"
     424             : "\n"
     425             : "A string is a digit string if all characters in the string are digits and there\n"
     426             : "is at least one character in the string.");
     427             : 
     428             : #define UNICODE_ISDIGIT_METHODDEF    \
     429             :     {"isdigit", (PyCFunction)unicode_isdigit, METH_NOARGS, unicode_isdigit__doc__},
     430             : 
     431             : static PyObject *
     432             : unicode_isdigit_impl(PyObject *self);
     433             : 
     434             : static PyObject *
     435     2250460 : unicode_isdigit(PyObject *self, PyObject *Py_UNUSED(ignored))
     436             : {
     437     2250460 :     return unicode_isdigit_impl(self);
     438             : }
     439             : 
     440             : PyDoc_STRVAR(unicode_isnumeric__doc__,
     441             : "isnumeric($self, /)\n"
     442             : "--\n"
     443             : "\n"
     444             : "Return True if the string is a numeric string, False otherwise.\n"
     445             : "\n"
     446             : "A string is numeric if all characters in the string are numeric and there is at\n"
     447             : "least one character in the string.");
     448             : 
     449             : #define UNICODE_ISNUMERIC_METHODDEF    \
     450             :     {"isnumeric", (PyCFunction)unicode_isnumeric, METH_NOARGS, unicode_isnumeric__doc__},
     451             : 
     452             : static PyObject *
     453             : unicode_isnumeric_impl(PyObject *self);
     454             : 
     455             : static PyObject *
     456     2228250 : unicode_isnumeric(PyObject *self, PyObject *Py_UNUSED(ignored))
     457             : {
     458     2228250 :     return unicode_isnumeric_impl(self);
     459             : }
     460             : 
     461             : PyDoc_STRVAR(unicode_isidentifier__doc__,
     462             : "isidentifier($self, /)\n"
     463             : "--\n"
     464             : "\n"
     465             : "Return True if the string is a valid Python identifier, False otherwise.\n"
     466             : "\n"
     467             : "Call keyword.iskeyword(s) to test whether string s is a reserved identifier,\n"
     468             : "such as \"def\" or \"class\".");
     469             : 
     470             : #define UNICODE_ISIDENTIFIER_METHODDEF    \
     471             :     {"isidentifier", (PyCFunction)unicode_isidentifier, METH_NOARGS, unicode_isidentifier__doc__},
     472             : 
     473             : static PyObject *
     474             : unicode_isidentifier_impl(PyObject *self);
     475             : 
     476             : static PyObject *
     477     5976600 : unicode_isidentifier(PyObject *self, PyObject *Py_UNUSED(ignored))
     478             : {
     479     5976600 :     return unicode_isidentifier_impl(self);
     480             : }
     481             : 
     482             : PyDoc_STRVAR(unicode_isprintable__doc__,
     483             : "isprintable($self, /)\n"
     484             : "--\n"
     485             : "\n"
     486             : "Return True if the string is printable, False otherwise.\n"
     487             : "\n"
     488             : "A string is printable if all of its characters are considered printable in\n"
     489             : "repr() or if it is empty.");
     490             : 
     491             : #define UNICODE_ISPRINTABLE_METHODDEF    \
     492             :     {"isprintable", (PyCFunction)unicode_isprintable, METH_NOARGS, unicode_isprintable__doc__},
     493             : 
     494             : static PyObject *
     495             : unicode_isprintable_impl(PyObject *self);
     496             : 
     497             : static PyObject *
     498     1422190 : unicode_isprintable(PyObject *self, PyObject *Py_UNUSED(ignored))
     499             : {
     500     1422190 :     return unicode_isprintable_impl(self);
     501             : }
     502             : 
     503             : PyDoc_STRVAR(unicode_join__doc__,
     504             : "join($self, iterable, /)\n"
     505             : "--\n"
     506             : "\n"
     507             : "Concatenate any number of strings.\n"
     508             : "\n"
     509             : "The string whose method is called is inserted in between each given string.\n"
     510             : "The result is returned as a new string.\n"
     511             : "\n"
     512             : "Example: \'.\'.join([\'ab\', \'pq\', \'rs\']) -> \'ab.pq.rs\'");
     513             : 
     514             : #define UNICODE_JOIN_METHODDEF    \
     515             :     {"join", (PyCFunction)unicode_join, METH_O, unicode_join__doc__},
     516             : 
     517             : PyDoc_STRVAR(unicode_ljust__doc__,
     518             : "ljust($self, width, fillchar=\' \', /)\n"
     519             : "--\n"
     520             : "\n"
     521             : "Return a left-justified string of length width.\n"
     522             : "\n"
     523             : "Padding is done using the specified fill character (default is a space).");
     524             : 
     525             : #define UNICODE_LJUST_METHODDEF    \
     526             :     {"ljust", _PyCFunction_CAST(unicode_ljust), METH_FASTCALL, unicode_ljust__doc__},
     527             : 
     528             : static PyObject *
     529             : unicode_ljust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar);
     530             : 
     531             : static PyObject *
     532       25594 : unicode_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     533             : {
     534       25594 :     PyObject *return_value = NULL;
     535             :     Py_ssize_t width;
     536       25594 :     Py_UCS4 fillchar = ' ';
     537             : 
     538       25594 :     if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) {
     539           1 :         goto exit;
     540             :     }
     541             :     {
     542       25593 :         Py_ssize_t ival = -1;
     543       25593 :         PyObject *iobj = _PyNumber_Index(args[0]);
     544       25593 :         if (iobj != NULL) {
     545       25593 :             ival = PyLong_AsSsize_t(iobj);
     546       25593 :             Py_DECREF(iobj);
     547             :         }
     548       25593 :         if (ival == -1 && PyErr_Occurred()) {
     549           0 :             goto exit;
     550             :         }
     551       25593 :         width = ival;
     552             :     }
     553       25593 :     if (nargs < 2) {
     554       25568 :         goto skip_optional;
     555             :     }
     556          25 :     if (!convert_uc(args[1], &fillchar)) {
     557           0 :         goto exit;
     558             :     }
     559          25 : skip_optional:
     560       25593 :     return_value = unicode_ljust_impl(self, width, fillchar);
     561             : 
     562       25594 : exit:
     563       25594 :     return return_value;
     564             : }
     565             : 
     566             : PyDoc_STRVAR(unicode_lower__doc__,
     567             : "lower($self, /)\n"
     568             : "--\n"
     569             : "\n"
     570             : "Return a copy of the string converted to lowercase.");
     571             : 
     572             : #define UNICODE_LOWER_METHODDEF    \
     573             :     {"lower", (PyCFunction)unicode_lower, METH_NOARGS, unicode_lower__doc__},
     574             : 
     575             : static PyObject *
     576             : unicode_lower_impl(PyObject *self);
     577             : 
     578             : static PyObject *
     579     4048230 : unicode_lower(PyObject *self, PyObject *Py_UNUSED(ignored))
     580             : {
     581     4048230 :     return unicode_lower_impl(self);
     582             : }
     583             : 
     584             : PyDoc_STRVAR(unicode_strip__doc__,
     585             : "strip($self, chars=None, /)\n"
     586             : "--\n"
     587             : "\n"
     588             : "Return a copy of the string with leading and trailing whitespace removed.\n"
     589             : "\n"
     590             : "If chars is given and not None, remove characters in chars instead.");
     591             : 
     592             : #define UNICODE_STRIP_METHODDEF    \
     593             :     {"strip", _PyCFunction_CAST(unicode_strip), METH_FASTCALL, unicode_strip__doc__},
     594             : 
     595             : static PyObject *
     596             : unicode_strip_impl(PyObject *self, PyObject *chars);
     597             : 
     598             : static PyObject *
     599     1138010 : unicode_strip(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     600             : {
     601     1138010 :     PyObject *return_value = NULL;
     602     1138010 :     PyObject *chars = Py_None;
     603             : 
     604     1138010 :     if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) {
     605           1 :         goto exit;
     606             :     }
     607     1138010 :     if (nargs < 1) {
     608     1099090 :         goto skip_optional;
     609             :     }
     610       38917 :     chars = args[0];
     611     1138010 : skip_optional:
     612     1138010 :     return_value = unicode_strip_impl(self, chars);
     613             : 
     614     1138010 : exit:
     615     1138010 :     return return_value;
     616             : }
     617             : 
     618             : PyDoc_STRVAR(unicode_lstrip__doc__,
     619             : "lstrip($self, chars=None, /)\n"
     620             : "--\n"
     621             : "\n"
     622             : "Return a copy of the string with leading whitespace removed.\n"
     623             : "\n"
     624             : "If chars is given and not None, remove characters in chars instead.");
     625             : 
     626             : #define UNICODE_LSTRIP_METHODDEF    \
     627             :     {"lstrip", _PyCFunction_CAST(unicode_lstrip), METH_FASTCALL, unicode_lstrip__doc__},
     628             : 
     629             : static PyObject *
     630             : unicode_lstrip_impl(PyObject *self, PyObject *chars);
     631             : 
     632             : static PyObject *
     633      232905 : unicode_lstrip(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     634             : {
     635      232905 :     PyObject *return_value = NULL;
     636      232905 :     PyObject *chars = Py_None;
     637             : 
     638      232905 :     if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) {
     639           1 :         goto exit;
     640             :     }
     641      232904 :     if (nargs < 1) {
     642       31436 :         goto skip_optional;
     643             :     }
     644      201468 :     chars = args[0];
     645      232904 : skip_optional:
     646      232904 :     return_value = unicode_lstrip_impl(self, chars);
     647             : 
     648      232905 : exit:
     649      232905 :     return return_value;
     650             : }
     651             : 
     652             : PyDoc_STRVAR(unicode_rstrip__doc__,
     653             : "rstrip($self, chars=None, /)\n"
     654             : "--\n"
     655             : "\n"
     656             : "Return a copy of the string with trailing whitespace removed.\n"
     657             : "\n"
     658             : "If chars is given and not None, remove characters in chars instead.");
     659             : 
     660             : #define UNICODE_RSTRIP_METHODDEF    \
     661             :     {"rstrip", _PyCFunction_CAST(unicode_rstrip), METH_FASTCALL, unicode_rstrip__doc__},
     662             : 
     663             : static PyObject *
     664             : unicode_rstrip_impl(PyObject *self, PyObject *chars);
     665             : 
     666             : static PyObject *
     667     6814170 : unicode_rstrip(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     668             : {
     669     6814170 :     PyObject *return_value = NULL;
     670     6814170 :     PyObject *chars = Py_None;
     671             : 
     672     6814170 :     if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) {
     673           1 :         goto exit;
     674             :     }
     675     6814170 :     if (nargs < 1) {
     676       74511 :         goto skip_optional;
     677             :     }
     678     6739660 :     chars = args[0];
     679     6814170 : skip_optional:
     680     6814170 :     return_value = unicode_rstrip_impl(self, chars);
     681             : 
     682     6814170 : exit:
     683     6814170 :     return return_value;
     684             : }
     685             : 
     686             : PyDoc_STRVAR(unicode_replace__doc__,
     687             : "replace($self, old, new, count=-1, /)\n"
     688             : "--\n"
     689             : "\n"
     690             : "Return a copy with all occurrences of substring old replaced by new.\n"
     691             : "\n"
     692             : "  count\n"
     693             : "    Maximum number of occurrences to replace.\n"
     694             : "    -1 (the default value) means replace all occurrences.\n"
     695             : "\n"
     696             : "If the optional argument count is given, only the first count occurrences are\n"
     697             : "replaced.");
     698             : 
     699             : #define UNICODE_REPLACE_METHODDEF    \
     700             :     {"replace", _PyCFunction_CAST(unicode_replace), METH_FASTCALL, unicode_replace__doc__},
     701             : 
     702             : static PyObject *
     703             : unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new,
     704             :                      Py_ssize_t count);
     705             : 
     706             : static PyObject *
     707     3239050 : unicode_replace(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     708             : {
     709     3239050 :     PyObject *return_value = NULL;
     710             :     PyObject *old;
     711             :     PyObject *new;
     712     3239050 :     Py_ssize_t count = -1;
     713             : 
     714     3239050 :     if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) {
     715           2 :         goto exit;
     716             :     }
     717     3239050 :     if (!PyUnicode_Check(args[0])) {
     718           5 :         _PyArg_BadArgument("replace", "argument 1", "str", args[0]);
     719           5 :         goto exit;
     720             :     }
     721     3239040 :     if (PyUnicode_READY(args[0]) == -1) {
     722           0 :         goto exit;
     723             :     }
     724     3239040 :     old = args[0];
     725     3239040 :     if (!PyUnicode_Check(args[1])) {
     726           3 :         _PyArg_BadArgument("replace", "argument 2", "str", args[1]);
     727           3 :         goto exit;
     728             :     }
     729     3239040 :     if (PyUnicode_READY(args[1]) == -1) {
     730           0 :         goto exit;
     731             :     }
     732     3239040 :     new = args[1];
     733     3239040 :     if (nargs < 3) {
     734     3174050 :         goto skip_optional;
     735             :     }
     736             :     {
     737       64989 :         Py_ssize_t ival = -1;
     738       64989 :         PyObject *iobj = _PyNumber_Index(args[2]);
     739       64989 :         if (iobj != NULL) {
     740       64989 :             ival = PyLong_AsSsize_t(iobj);
     741       64989 :             Py_DECREF(iobj);
     742             :         }
     743       64989 :         if (ival == -1 && PyErr_Occurred()) {
     744           0 :             goto exit;
     745             :         }
     746       64989 :         count = ival;
     747             :     }
     748     3239040 : skip_optional:
     749     3239040 :     return_value = unicode_replace_impl(self, old, new, count);
     750             : 
     751     3239050 : exit:
     752     3239050 :     return return_value;
     753             : }
     754             : 
     755             : PyDoc_STRVAR(unicode_removeprefix__doc__,
     756             : "removeprefix($self, prefix, /)\n"
     757             : "--\n"
     758             : "\n"
     759             : "Return a str with the given prefix string removed if present.\n"
     760             : "\n"
     761             : "If the string starts with the prefix string, return string[len(prefix):].\n"
     762             : "Otherwise, return a copy of the original string.");
     763             : 
     764             : #define UNICODE_REMOVEPREFIX_METHODDEF    \
     765             :     {"removeprefix", (PyCFunction)unicode_removeprefix, METH_O, unicode_removeprefix__doc__},
     766             : 
     767             : static PyObject *
     768             : unicode_removeprefix_impl(PyObject *self, PyObject *prefix);
     769             : 
     770             : static PyObject *
     771       30318 : unicode_removeprefix(PyObject *self, PyObject *arg)
     772             : {
     773       30318 :     PyObject *return_value = NULL;
     774             :     PyObject *prefix;
     775             : 
     776       30318 :     if (!PyUnicode_Check(arg)) {
     777           4 :         _PyArg_BadArgument("removeprefix", "argument", "str", arg);
     778           4 :         goto exit;
     779             :     }
     780       30314 :     if (PyUnicode_READY(arg) == -1) {
     781           0 :         goto exit;
     782             :     }
     783       30314 :     prefix = arg;
     784       30314 :     return_value = unicode_removeprefix_impl(self, prefix);
     785             : 
     786       30318 : exit:
     787       30318 :     return return_value;
     788             : }
     789             : 
     790             : PyDoc_STRVAR(unicode_removesuffix__doc__,
     791             : "removesuffix($self, suffix, /)\n"
     792             : "--\n"
     793             : "\n"
     794             : "Return a str with the given suffix string removed if present.\n"
     795             : "\n"
     796             : "If the string ends with the suffix string and that suffix is not empty,\n"
     797             : "return string[:-len(suffix)]. Otherwise, return a copy of the original\n"
     798             : "string.");
     799             : 
     800             : #define UNICODE_REMOVESUFFIX_METHODDEF    \
     801             :     {"removesuffix", (PyCFunction)unicode_removesuffix, METH_O, unicode_removesuffix__doc__},
     802             : 
     803             : static PyObject *
     804             : unicode_removesuffix_impl(PyObject *self, PyObject *suffix);
     805             : 
     806             : static PyObject *
     807          32 : unicode_removesuffix(PyObject *self, PyObject *arg)
     808             : {
     809          32 :     PyObject *return_value = NULL;
     810             :     PyObject *suffix;
     811             : 
     812          32 :     if (!PyUnicode_Check(arg)) {
     813           4 :         _PyArg_BadArgument("removesuffix", "argument", "str", arg);
     814           4 :         goto exit;
     815             :     }
     816          28 :     if (PyUnicode_READY(arg) == -1) {
     817           0 :         goto exit;
     818             :     }
     819          28 :     suffix = arg;
     820          28 :     return_value = unicode_removesuffix_impl(self, suffix);
     821             : 
     822          32 : exit:
     823          32 :     return return_value;
     824             : }
     825             : 
     826             : PyDoc_STRVAR(unicode_rjust__doc__,
     827             : "rjust($self, width, fillchar=\' \', /)\n"
     828             : "--\n"
     829             : "\n"
     830             : "Return a right-justified string of length width.\n"
     831             : "\n"
     832             : "Padding is done using the specified fill character (default is a space).");
     833             : 
     834             : #define UNICODE_RJUST_METHODDEF    \
     835             :     {"rjust", _PyCFunction_CAST(unicode_rjust), METH_FASTCALL, unicode_rjust__doc__},
     836             : 
     837             : static PyObject *
     838             : unicode_rjust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar);
     839             : 
     840             : static PyObject *
     841       48280 : unicode_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     842             : {
     843       48280 :     PyObject *return_value = NULL;
     844             :     Py_ssize_t width;
     845       48280 :     Py_UCS4 fillchar = ' ';
     846             : 
     847       48280 :     if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) {
     848           1 :         goto exit;
     849             :     }
     850             :     {
     851       48279 :         Py_ssize_t ival = -1;
     852       48279 :         PyObject *iobj = _PyNumber_Index(args[0]);
     853       48279 :         if (iobj != NULL) {
     854       48279 :             ival = PyLong_AsSsize_t(iobj);
     855       48279 :             Py_DECREF(iobj);
     856             :         }
     857       48279 :         if (ival == -1 && PyErr_Occurred()) {
     858           0 :             goto exit;
     859             :         }
     860       48279 :         width = ival;
     861             :     }
     862       48279 :     if (nargs < 2) {
     863       48247 :         goto skip_optional;
     864             :     }
     865          32 :     if (!convert_uc(args[1], &fillchar)) {
     866           0 :         goto exit;
     867             :     }
     868          32 : skip_optional:
     869       48279 :     return_value = unicode_rjust_impl(self, width, fillchar);
     870             : 
     871       48280 : exit:
     872       48280 :     return return_value;
     873             : }
     874             : 
     875             : PyDoc_STRVAR(unicode_split__doc__,
     876             : "split($self, /, sep=None, maxsplit=-1)\n"
     877             : "--\n"
     878             : "\n"
     879             : "Return a list of the substrings in the string, using sep as the separator string.\n"
     880             : "\n"
     881             : "  sep\n"
     882             : "    The separator used to split the string.\n"
     883             : "\n"
     884             : "    When set to None (the default value), will split on any whitespace\n"
     885             : "    character (including \\\\n \\\\r \\\\t \\\\f and spaces) and will discard\n"
     886             : "    empty strings from the result.\n"
     887             : "  maxsplit\n"
     888             : "    Maximum number of splits (starting from the left).\n"
     889             : "    -1 (the default value) means no limit.\n"
     890             : "\n"
     891             : "Note, str.split() is mainly useful for data that has been intentionally\n"
     892             : "delimited.  With natural text that includes punctuation, consider using\n"
     893             : "the regular expression module.");
     894             : 
     895             : #define UNICODE_SPLIT_METHODDEF    \
     896             :     {"split", _PyCFunction_CAST(unicode_split), METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__},
     897             : 
     898             : static PyObject *
     899             : unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit);
     900             : 
     901             : static PyObject *
     902     2172230 : unicode_split(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     903             : {
     904     2172230 :     PyObject *return_value = NULL;
     905             :     static const char * const _keywords[] = {"sep", "maxsplit", NULL};
     906             :     static _PyArg_Parser _parser = {NULL, _keywords, "split", 0};
     907             :     PyObject *argsbuf[2];
     908     2172230 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     909     2172230 :     PyObject *sep = Py_None;
     910     2172230 :     Py_ssize_t maxsplit = -1;
     911             : 
     912     2172230 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
     913     2172230 :     if (!args) {
     914           1 :         goto exit;
     915             :     }
     916     2172230 :     if (!noptargs) {
     917      476486 :         goto skip_optional_pos;
     918             :     }
     919     1695750 :     if (args[0]) {
     920     1694530 :         sep = args[0];
     921     1694530 :         if (!--noptargs) {
     922     1618500 :             goto skip_optional_pos;
     923             :         }
     924             :     }
     925             :     {
     926       77242 :         Py_ssize_t ival = -1;
     927       77242 :         PyObject *iobj = _PyNumber_Index(args[1]);
     928       77242 :         if (iobj != NULL) {
     929       77242 :             ival = PyLong_AsSsize_t(iobj);
     930       77242 :             Py_DECREF(iobj);
     931             :         }
     932       77242 :         if (ival == -1 && PyErr_Occurred()) {
     933           0 :             goto exit;
     934             :         }
     935       77242 :         maxsplit = ival;
     936             :     }
     937     2172230 : skip_optional_pos:
     938     2172230 :     return_value = unicode_split_impl(self, sep, maxsplit);
     939             : 
     940     2172230 : exit:
     941     2172230 :     return return_value;
     942             : }
     943             : 
     944             : PyDoc_STRVAR(unicode_partition__doc__,
     945             : "partition($self, sep, /)\n"
     946             : "--\n"
     947             : "\n"
     948             : "Partition the string into three parts using the given separator.\n"
     949             : "\n"
     950             : "This will search for the separator in the string.  If the separator is found,\n"
     951             : "returns a 3-tuple containing the part before the separator, the separator\n"
     952             : "itself, and the part after it.\n"
     953             : "\n"
     954             : "If the separator is not found, returns a 3-tuple containing the original string\n"
     955             : "and two empty strings.");
     956             : 
     957             : #define UNICODE_PARTITION_METHODDEF    \
     958             :     {"partition", (PyCFunction)unicode_partition, METH_O, unicode_partition__doc__},
     959             : 
     960             : PyDoc_STRVAR(unicode_rpartition__doc__,
     961             : "rpartition($self, sep, /)\n"
     962             : "--\n"
     963             : "\n"
     964             : "Partition the string into three parts using the given separator.\n"
     965             : "\n"
     966             : "This will search for the separator in the string, starting at the end. If\n"
     967             : "the separator is found, returns a 3-tuple containing the part before the\n"
     968             : "separator, the separator itself, and the part after it.\n"
     969             : "\n"
     970             : "If the separator is not found, returns a 3-tuple containing two empty strings\n"
     971             : "and the original string.");
     972             : 
     973             : #define UNICODE_RPARTITION_METHODDEF    \
     974             :     {"rpartition", (PyCFunction)unicode_rpartition, METH_O, unicode_rpartition__doc__},
     975             : 
     976             : PyDoc_STRVAR(unicode_rsplit__doc__,
     977             : "rsplit($self, /, sep=None, maxsplit=-1)\n"
     978             : "--\n"
     979             : "\n"
     980             : "Return a list of the substrings in the string, using sep as the separator string.\n"
     981             : "\n"
     982             : "  sep\n"
     983             : "    The separator used to split the string.\n"
     984             : "\n"
     985             : "    When set to None (the default value), will split on any whitespace\n"
     986             : "    character (including \\\\n \\\\r \\\\t \\\\f and spaces) and will discard\n"
     987             : "    empty strings from the result.\n"
     988             : "  maxsplit\n"
     989             : "    Maximum number of splits (starting from the left).\n"
     990             : "    -1 (the default value) means no limit.\n"
     991             : "\n"
     992             : "Splitting starts at the end of the string and works to the front.");
     993             : 
     994             : #define UNICODE_RSPLIT_METHODDEF    \
     995             :     {"rsplit", _PyCFunction_CAST(unicode_rsplit), METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__},
     996             : 
     997             : static PyObject *
     998             : unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit);
     999             : 
    1000             : static PyObject *
    1001        3825 : unicode_rsplit(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1002             : {
    1003        3825 :     PyObject *return_value = NULL;
    1004             :     static const char * const _keywords[] = {"sep", "maxsplit", NULL};
    1005             :     static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0};
    1006             :     PyObject *argsbuf[2];
    1007        3825 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
    1008        3825 :     PyObject *sep = Py_None;
    1009        3825 :     Py_ssize_t maxsplit = -1;
    1010             : 
    1011        3825 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
    1012        3825 :     if (!args) {
    1013           1 :         goto exit;
    1014             :     }
    1015        3824 :     if (!noptargs) {
    1016          11 :         goto skip_optional_pos;
    1017             :     }
    1018        3813 :     if (args[0]) {
    1019        3812 :         sep = args[0];
    1020        3812 :         if (!--noptargs) {
    1021          63 :             goto skip_optional_pos;
    1022             :         }
    1023             :     }
    1024             :     {
    1025        3750 :         Py_ssize_t ival = -1;
    1026        3750 :         PyObject *iobj = _PyNumber_Index(args[1]);
    1027        3750 :         if (iobj != NULL) {
    1028        3750 :             ival = PyLong_AsSsize_t(iobj);
    1029        3750 :             Py_DECREF(iobj);
    1030             :         }
    1031        3750 :         if (ival == -1 && PyErr_Occurred()) {
    1032           0 :             goto exit;
    1033             :         }
    1034        3750 :         maxsplit = ival;
    1035             :     }
    1036        3824 : skip_optional_pos:
    1037        3824 :     return_value = unicode_rsplit_impl(self, sep, maxsplit);
    1038             : 
    1039        3825 : exit:
    1040        3825 :     return return_value;
    1041             : }
    1042             : 
    1043             : PyDoc_STRVAR(unicode_splitlines__doc__,
    1044             : "splitlines($self, /, keepends=False)\n"
    1045             : "--\n"
    1046             : "\n"
    1047             : "Return a list of the lines in the string, breaking at line boundaries.\n"
    1048             : "\n"
    1049             : "Line breaks are not included in the resulting list unless keepends is given and\n"
    1050             : "true.");
    1051             : 
    1052             : #define UNICODE_SPLITLINES_METHODDEF    \
    1053             :     {"splitlines", _PyCFunction_CAST(unicode_splitlines), METH_FASTCALL|METH_KEYWORDS, unicode_splitlines__doc__},
    1054             : 
    1055             : static PyObject *
    1056             : unicode_splitlines_impl(PyObject *self, int keepends);
    1057             : 
    1058             : static PyObject *
    1059      287965 : unicode_splitlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1060             : {
    1061      287965 :     PyObject *return_value = NULL;
    1062             :     static const char * const _keywords[] = {"keepends", NULL};
    1063             :     static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0};
    1064             :     PyObject *argsbuf[1];
    1065      287965 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
    1066      287965 :     int keepends = 0;
    1067             : 
    1068      287965 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
    1069      287965 :     if (!args) {
    1070           1 :         goto exit;
    1071             :     }
    1072      287964 :     if (!noptargs) {
    1073       75137 :         goto skip_optional_pos;
    1074             :     }
    1075      212827 :     keepends = _PyLong_AsInt(args[0]);
    1076      212827 :     if (keepends == -1 && PyErr_Occurred()) {
    1077           0 :         goto exit;
    1078             :     }
    1079      212827 : skip_optional_pos:
    1080      287964 :     return_value = unicode_splitlines_impl(self, keepends);
    1081             : 
    1082      287965 : exit:
    1083      287965 :     return return_value;
    1084             : }
    1085             : 
    1086             : PyDoc_STRVAR(unicode_swapcase__doc__,
    1087             : "swapcase($self, /)\n"
    1088             : "--\n"
    1089             : "\n"
    1090             : "Convert uppercase characters to lowercase and lowercase characters to uppercase.");
    1091             : 
    1092             : #define UNICODE_SWAPCASE_METHODDEF    \
    1093             :     {"swapcase", (PyCFunction)unicode_swapcase, METH_NOARGS, unicode_swapcase__doc__},
    1094             : 
    1095             : static PyObject *
    1096             : unicode_swapcase_impl(PyObject *self);
    1097             : 
    1098             : static PyObject *
    1099          29 : unicode_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored))
    1100             : {
    1101          29 :     return unicode_swapcase_impl(self);
    1102             : }
    1103             : 
    1104             : PyDoc_STRVAR(unicode_maketrans__doc__,
    1105             : "maketrans(x, y=<unrepresentable>, z=<unrepresentable>, /)\n"
    1106             : "--\n"
    1107             : "\n"
    1108             : "Return a translation table usable for str.translate().\n"
    1109             : "\n"
    1110             : "If there is only one argument, it must be a dictionary mapping Unicode\n"
    1111             : "ordinals (integers) or characters to Unicode ordinals, strings or None.\n"
    1112             : "Character keys will be then converted to ordinals.\n"
    1113             : "If there are two arguments, they must be strings of equal length, and\n"
    1114             : "in the resulting dictionary, each character in x will be mapped to the\n"
    1115             : "character at the same position in y. If there is a third argument, it\n"
    1116             : "must be a string, whose characters will be mapped to None in the result.");
    1117             : 
    1118             : #define UNICODE_MAKETRANS_METHODDEF    \
    1119             :     {"maketrans", _PyCFunction_CAST(unicode_maketrans), METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__},
    1120             : 
    1121             : static PyObject *
    1122             : unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z);
    1123             : 
    1124             : static PyObject *
    1125         141 : unicode_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
    1126             : {
    1127         141 :     PyObject *return_value = NULL;
    1128             :     PyObject *x;
    1129         141 :     PyObject *y = NULL;
    1130         141 :     PyObject *z = NULL;
    1131             : 
    1132         141 :     if (!_PyArg_CheckPositional("maketrans", nargs, 1, 3)) {
    1133           1 :         goto exit;
    1134             :     }
    1135         140 :     x = args[0];
    1136         140 :     if (nargs < 2) {
    1137         111 :         goto skip_optional;
    1138             :     }
    1139          29 :     if (!PyUnicode_Check(args[1])) {
    1140           1 :         _PyArg_BadArgument("maketrans", "argument 2", "str", args[1]);
    1141           1 :         goto exit;
    1142             :     }
    1143          28 :     if (PyUnicode_READY(args[1]) == -1) {
    1144           0 :         goto exit;
    1145             :     }
    1146          28 :     y = args[1];
    1147          28 :     if (nargs < 3) {
    1148          25 :         goto skip_optional;
    1149             :     }
    1150           3 :     if (!PyUnicode_Check(args[2])) {
    1151           1 :         _PyArg_BadArgument("maketrans", "argument 3", "str", args[2]);
    1152           1 :         goto exit;
    1153             :     }
    1154           2 :     if (PyUnicode_READY(args[2]) == -1) {
    1155           0 :         goto exit;
    1156             :     }
    1157           2 :     z = args[2];
    1158         138 : skip_optional:
    1159         138 :     return_value = unicode_maketrans_impl(x, y, z);
    1160             : 
    1161         141 : exit:
    1162         141 :     return return_value;
    1163             : }
    1164             : 
    1165             : PyDoc_STRVAR(unicode_translate__doc__,
    1166             : "translate($self, table, /)\n"
    1167             : "--\n"
    1168             : "\n"
    1169             : "Replace each character in the string using the given translation table.\n"
    1170             : "\n"
    1171             : "  table\n"
    1172             : "    Translation table, which must be a mapping of Unicode ordinals to\n"
    1173             : "    Unicode ordinals, strings, or None.\n"
    1174             : "\n"
    1175             : "The table must implement lookup/indexing via __getitem__, for instance a\n"
    1176             : "dictionary or list.  If this operation raises LookupError, the character is\n"
    1177             : "left untouched.  Characters mapped to None are deleted.");
    1178             : 
    1179             : #define UNICODE_TRANSLATE_METHODDEF    \
    1180             :     {"translate", (PyCFunction)unicode_translate, METH_O, unicode_translate__doc__},
    1181             : 
    1182             : PyDoc_STRVAR(unicode_upper__doc__,
    1183             : "upper($self, /)\n"
    1184             : "--\n"
    1185             : "\n"
    1186             : "Return a copy of the string converted to uppercase.");
    1187             : 
    1188             : #define UNICODE_UPPER_METHODDEF    \
    1189             :     {"upper", (PyCFunction)unicode_upper, METH_NOARGS, unicode_upper__doc__},
    1190             : 
    1191             : static PyObject *
    1192             : unicode_upper_impl(PyObject *self);
    1193             : 
    1194             : static PyObject *
    1195     3413000 : unicode_upper(PyObject *self, PyObject *Py_UNUSED(ignored))
    1196             : {
    1197     3413000 :     return unicode_upper_impl(self);
    1198             : }
    1199             : 
    1200             : PyDoc_STRVAR(unicode_zfill__doc__,
    1201             : "zfill($self, width, /)\n"
    1202             : "--\n"
    1203             : "\n"
    1204             : "Pad a numeric string with zeros on the left, to fill a field of the given width.\n"
    1205             : "\n"
    1206             : "The string is never truncated.");
    1207             : 
    1208             : #define UNICODE_ZFILL_METHODDEF    \
    1209             :     {"zfill", (PyCFunction)unicode_zfill, METH_O, unicode_zfill__doc__},
    1210             : 
    1211             : static PyObject *
    1212             : unicode_zfill_impl(PyObject *self, Py_ssize_t width);
    1213             : 
    1214             : static PyObject *
    1215          64 : unicode_zfill(PyObject *self, PyObject *arg)
    1216             : {
    1217          64 :     PyObject *return_value = NULL;
    1218             :     Py_ssize_t width;
    1219             : 
    1220             :     {
    1221          64 :         Py_ssize_t ival = -1;
    1222          64 :         PyObject *iobj = _PyNumber_Index(arg);
    1223          64 :         if (iobj != NULL) {
    1224          64 :             ival = PyLong_AsSsize_t(iobj);
    1225          64 :             Py_DECREF(iobj);
    1226             :         }
    1227          64 :         if (ival == -1 && PyErr_Occurred()) {
    1228           0 :             goto exit;
    1229             :         }
    1230          64 :         width = ival;
    1231             :     }
    1232          64 :     return_value = unicode_zfill_impl(self, width);
    1233             : 
    1234          64 : exit:
    1235          64 :     return return_value;
    1236             : }
    1237             : 
    1238             : PyDoc_STRVAR(unicode___format____doc__,
    1239             : "__format__($self, format_spec, /)\n"
    1240             : "--\n"
    1241             : "\n"
    1242             : "Return a formatted version of the string as described by format_spec.");
    1243             : 
    1244             : #define UNICODE___FORMAT___METHODDEF    \
    1245             :     {"__format__", (PyCFunction)unicode___format__, METH_O, unicode___format____doc__},
    1246             : 
    1247             : static PyObject *
    1248             : unicode___format___impl(PyObject *self, PyObject *format_spec);
    1249             : 
    1250             : static PyObject *
    1251        7931 : unicode___format__(PyObject *self, PyObject *arg)
    1252             : {
    1253        7931 :     PyObject *return_value = NULL;
    1254             :     PyObject *format_spec;
    1255             : 
    1256        7931 :     if (!PyUnicode_Check(arg)) {
    1257           0 :         _PyArg_BadArgument("__format__", "argument", "str", arg);
    1258           0 :         goto exit;
    1259             :     }
    1260        7931 :     if (PyUnicode_READY(arg) == -1) {
    1261           0 :         goto exit;
    1262             :     }
    1263        7931 :     format_spec = arg;
    1264        7931 :     return_value = unicode___format___impl(self, format_spec);
    1265             : 
    1266        7931 : exit:
    1267        7931 :     return return_value;
    1268             : }
    1269             : 
    1270             : PyDoc_STRVAR(unicode_sizeof__doc__,
    1271             : "__sizeof__($self, /)\n"
    1272             : "--\n"
    1273             : "\n"
    1274             : "Return the size of the string in memory, in bytes.");
    1275             : 
    1276             : #define UNICODE_SIZEOF_METHODDEF    \
    1277             :     {"__sizeof__", (PyCFunction)unicode_sizeof, METH_NOARGS, unicode_sizeof__doc__},
    1278             : 
    1279             : static PyObject *
    1280             : unicode_sizeof_impl(PyObject *self);
    1281             : 
    1282             : static PyObject *
    1283          12 : unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
    1284             : {
    1285          12 :     return unicode_sizeof_impl(self);
    1286             : }
    1287             : 
    1288             : static PyObject *
    1289             : unicode_new_impl(PyTypeObject *type, PyObject *x, const char *encoding,
    1290             :                  const char *errors);
    1291             : 
    1292             : static PyObject *
    1293     1204770 : unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1294             : {
    1295     1204770 :     PyObject *return_value = NULL;
    1296             :     static const char * const _keywords[] = {"object", "encoding", "errors", NULL};
    1297             :     static _PyArg_Parser _parser = {NULL, _keywords, "str", 0};
    1298             :     PyObject *argsbuf[3];
    1299             :     PyObject * const *fastargs;
    1300     1204770 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
    1301     1204770 :     Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
    1302     1204770 :     PyObject *x = NULL;
    1303     1204770 :     const char *encoding = NULL;
    1304     1204770 :     const char *errors = NULL;
    1305             : 
    1306     1204770 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 3, 0, argsbuf);
    1307     1204770 :     if (!fastargs) {
    1308           3 :         goto exit;
    1309             :     }
    1310     1204770 :     if (!noptargs) {
    1311       15121 :         goto skip_optional_pos;
    1312             :     }
    1313     1189650 :     if (fastargs[0]) {
    1314     1189650 :         x = fastargs[0];
    1315     1189650 :         if (!--noptargs) {
    1316      730328 :             goto skip_optional_pos;
    1317             :         }
    1318             :     }
    1319      459320 :     if (fastargs[1]) {
    1320      459313 :         if (!PyUnicode_Check(fastargs[1])) {
    1321           3 :             _PyArg_BadArgument("str", "argument 'encoding'", "str", fastargs[1]);
    1322           3 :             goto exit;
    1323             :         }
    1324             :         Py_ssize_t encoding_length;
    1325      459310 :         encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length);
    1326      459310 :         if (encoding == NULL) {
    1327           0 :             goto exit;
    1328             :         }
    1329      459310 :         if (strlen(encoding) != (size_t)encoding_length) {
    1330           0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
    1331           0 :             goto exit;
    1332             :         }
    1333      459310 :         if (!--noptargs) {
    1334      248366 :             goto skip_optional_pos;
    1335             :         }
    1336             :     }
    1337      210951 :     if (!PyUnicode_Check(fastargs[2])) {
    1338           1 :         _PyArg_BadArgument("str", "argument 'errors'", "str", fastargs[2]);
    1339           1 :         goto exit;
    1340             :     }
    1341             :     Py_ssize_t errors_length;
    1342      210950 :     errors = PyUnicode_AsUTF8AndSize(fastargs[2], &errors_length);
    1343      210950 :     if (errors == NULL) {
    1344           0 :         goto exit;
    1345             :     }
    1346      210950 :     if (strlen(errors) != (size_t)errors_length) {
    1347           0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
    1348           0 :         goto exit;
    1349             :     }
    1350      210950 : skip_optional_pos:
    1351     1204760 :     return_value = unicode_new_impl(type, x, encoding, errors);
    1352             : 
    1353     1204770 : exit:
    1354     1204770 :     return return_value;
    1355             : }
    1356             : /*[clinic end generated code: output=b5dd7cefead9a8e7 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14