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