blob: 610178dc27de28cf32dd29c7ee223f1077a0efcb [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
INADA Naoki3ae20562017-01-16 20:41:20 +09005PyDoc_STRVAR(unicode_title__doc__,
6"title($self, /)\n"
7"--\n"
8"\n"
INADA Naoki15f94592017-01-16 21:49:13 +09009"Return a version of the string where each word is titlecased.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +090010"\n"
INADA Naoki15f94592017-01-16 21:49:13 +090011"More specifically, words start with uppercased characters and all remaining\n"
INADA Naoki3ae20562017-01-16 20:41:20 +090012"cased characters have lower case.");
13
14#define UNICODE_TITLE_METHODDEF \
15 {"title", (PyCFunction)unicode_title, METH_NOARGS, unicode_title__doc__},
16
17static PyObject *
18unicode_title_impl(PyObject *self);
19
20static PyObject *
21unicode_title(PyObject *self, PyObject *Py_UNUSED(ignored))
22{
23 return unicode_title_impl(self);
24}
25
26PyDoc_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
38static PyObject *
39unicode_capitalize_impl(PyObject *self);
40
41static PyObject *
42unicode_capitalize(PyObject *self, PyObject *Py_UNUSED(ignored))
43{
44 return unicode_capitalize_impl(self);
45}
46
47PyDoc_STRVAR(unicode_casefold__doc__,
48"casefold($self, /)\n"
49"--\n"
50"\n"
INADA Naoki15f94592017-01-16 21:49:13 +090051"Return a version of the string suitable for caseless comparisons.");
INADA Naoki3ae20562017-01-16 20:41:20 +090052
53#define UNICODE_CASEFOLD_METHODDEF \
54 {"casefold", (PyCFunction)unicode_casefold, METH_NOARGS, unicode_casefold__doc__},
55
56static PyObject *
57unicode_casefold_impl(PyObject *self);
58
59static PyObject *
60unicode_casefold(PyObject *self, PyObject *Py_UNUSED(ignored))
61{
62 return unicode_casefold_impl(self);
63}
64
65PyDoc_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)unicode_center, METH_VARARGS, unicode_center__doc__},
75
76static PyObject *
77unicode_center_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar);
78
79static PyObject *
80unicode_center(PyObject *self, PyObject *args)
81{
82 PyObject *return_value = NULL;
83 Py_ssize_t width;
84 Py_UCS4 fillchar = ' ';
85
86 if (!PyArg_ParseTuple(args, "n|O&:center",
87 &width, convert_uc, &fillchar)) {
88 goto exit;
89 }
90 return_value = unicode_center_impl(self, width, fillchar);
91
92exit:
93 return return_value;
94}
95
96PyDoc_STRVAR(unicode_encode__doc__,
97"encode($self, /, encoding=\'utf-8\', errors=\'strict\')\n"
98"--\n"
99"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900100"Encode the string using the codec registered for encoding.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900101"\n"
102" encoding\n"
103" The encoding in which to encode the string.\n"
104" errors\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900105" The error handling scheme to use for encoding errors.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900106" The default is \'strict\' meaning that encoding errors raise a\n"
107" UnicodeEncodeError. Other possible values are \'ignore\', \'replace\' and\n"
108" \'xmlcharrefreplace\' as well as any other name registered with\n"
109" codecs.register_error that can handle UnicodeEncodeErrors.");
110
111#define UNICODE_ENCODE_METHODDEF \
112 {"encode", (PyCFunction)unicode_encode, METH_FASTCALL, unicode_encode__doc__},
113
114static PyObject *
115unicode_encode_impl(PyObject *self, const char *encoding, const char *errors);
116
117static PyObject *
118unicode_encode(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
119{
120 PyObject *return_value = NULL;
121 static const char * const _keywords[] = {"encoding", "errors", NULL};
122 static _PyArg_Parser _parser = {"|ss:encode", _keywords, 0};
123 const char *encoding = NULL;
124 const char *errors = NULL;
125
126 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
127 &encoding, &errors)) {
128 goto exit;
129 }
130 return_value = unicode_encode_impl(self, encoding, errors);
131
132exit:
133 return return_value;
134}
135
136PyDoc_STRVAR(unicode_expandtabs__doc__,
137"expandtabs($self, /, tabsize=8)\n"
138"--\n"
139"\n"
140"Return a copy where all tab characters are expanded using spaces.\n"
141"\n"
142"If tabsize is not given, a tab size of 8 characters is assumed.");
143
144#define UNICODE_EXPANDTABS_METHODDEF \
145 {"expandtabs", (PyCFunction)unicode_expandtabs, METH_FASTCALL, unicode_expandtabs__doc__},
146
147static PyObject *
148unicode_expandtabs_impl(PyObject *self, int tabsize);
149
150static PyObject *
151unicode_expandtabs(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
152{
153 PyObject *return_value = NULL;
154 static const char * const _keywords[] = {"tabsize", NULL};
155 static _PyArg_Parser _parser = {"|i:expandtabs", _keywords, 0};
156 int tabsize = 8;
157
158 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
159 &tabsize)) {
160 goto exit;
161 }
162 return_value = unicode_expandtabs_impl(self, tabsize);
163
164exit:
165 return return_value;
166}
167
168PyDoc_STRVAR(unicode_islower__doc__,
169"islower($self, /)\n"
170"--\n"
171"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900172"Return True if the string is a lowercase string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900173"\n"
174"A string is lowercase if all cased characters in the string are lowercase and\n"
175"there is at least one cased character in the string.");
176
177#define UNICODE_ISLOWER_METHODDEF \
178 {"islower", (PyCFunction)unicode_islower, METH_NOARGS, unicode_islower__doc__},
179
180static PyObject *
181unicode_islower_impl(PyObject *self);
182
183static PyObject *
184unicode_islower(PyObject *self, PyObject *Py_UNUSED(ignored))
185{
186 return unicode_islower_impl(self);
187}
188
189PyDoc_STRVAR(unicode_isupper__doc__,
190"isupper($self, /)\n"
191"--\n"
192"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900193"Return True if the string is an uppercase string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900194"\n"
195"A string is uppercase if all cased characters in the string are uppercase and\n"
196"there is at least one cased character in the string.");
197
198#define UNICODE_ISUPPER_METHODDEF \
199 {"isupper", (PyCFunction)unicode_isupper, METH_NOARGS, unicode_isupper__doc__},
200
201static PyObject *
202unicode_isupper_impl(PyObject *self);
203
204static PyObject *
205unicode_isupper(PyObject *self, PyObject *Py_UNUSED(ignored))
206{
207 return unicode_isupper_impl(self);
208}
209
210PyDoc_STRVAR(unicode_istitle__doc__,
211"istitle($self, /)\n"
212"--\n"
213"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900214"Return True if the string is a title-cased string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900215"\n"
216"In a title-cased string, upper- and title-case characters may only\n"
217"follow uncased characters and lowercase characters only cased ones.");
218
219#define UNICODE_ISTITLE_METHODDEF \
220 {"istitle", (PyCFunction)unicode_istitle, METH_NOARGS, unicode_istitle__doc__},
221
222static PyObject *
223unicode_istitle_impl(PyObject *self);
224
225static PyObject *
226unicode_istitle(PyObject *self, PyObject *Py_UNUSED(ignored))
227{
228 return unicode_istitle_impl(self);
229}
230
231PyDoc_STRVAR(unicode_isspace__doc__,
232"isspace($self, /)\n"
233"--\n"
234"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900235"Return True if the string is a whitespace string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900236"\n"
237"A string is whitespace if all characters in the string are whitespace and there\n"
238"is at least one character in the string.");
239
240#define UNICODE_ISSPACE_METHODDEF \
241 {"isspace", (PyCFunction)unicode_isspace, METH_NOARGS, unicode_isspace__doc__},
242
243static PyObject *
244unicode_isspace_impl(PyObject *self);
245
246static PyObject *
247unicode_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))
248{
249 return unicode_isspace_impl(self);
250}
251
252PyDoc_STRVAR(unicode_isalpha__doc__,
253"isalpha($self, /)\n"
254"--\n"
255"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900256"Return True if the string is an alphabetic string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900257"\n"
258"A string is alphabetic if all characters in the string are alphabetic and there\n"
259"is at least one character in the string.");
260
261#define UNICODE_ISALPHA_METHODDEF \
262 {"isalpha", (PyCFunction)unicode_isalpha, METH_NOARGS, unicode_isalpha__doc__},
263
264static PyObject *
265unicode_isalpha_impl(PyObject *self);
266
267static PyObject *
268unicode_isalpha(PyObject *self, PyObject *Py_UNUSED(ignored))
269{
270 return unicode_isalpha_impl(self);
271}
272
273PyDoc_STRVAR(unicode_isalnum__doc__,
274"isalnum($self, /)\n"
275"--\n"
276"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900277"Return True if the string is an alpha-numeric string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900278"\n"
279"A string is alpha-numeric if all characters in the string are alpha-numeric and\n"
280"there is at least one character in the string.");
281
282#define UNICODE_ISALNUM_METHODDEF \
283 {"isalnum", (PyCFunction)unicode_isalnum, METH_NOARGS, unicode_isalnum__doc__},
284
285static PyObject *
286unicode_isalnum_impl(PyObject *self);
287
288static PyObject *
289unicode_isalnum(PyObject *self, PyObject *Py_UNUSED(ignored))
290{
291 return unicode_isalnum_impl(self);
292}
293
294PyDoc_STRVAR(unicode_isdecimal__doc__,
295"isdecimal($self, /)\n"
296"--\n"
297"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900298"Return True if the string is a decimal string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900299"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900300"A string is a decimal string if all characters in the string are decimal and\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900301"there is at least one character in the string.");
302
303#define UNICODE_ISDECIMAL_METHODDEF \
304 {"isdecimal", (PyCFunction)unicode_isdecimal, METH_NOARGS, unicode_isdecimal__doc__},
305
306static PyObject *
307unicode_isdecimal_impl(PyObject *self);
308
309static PyObject *
310unicode_isdecimal(PyObject *self, PyObject *Py_UNUSED(ignored))
311{
312 return unicode_isdecimal_impl(self);
313}
314
315PyDoc_STRVAR(unicode_isdigit__doc__,
316"isdigit($self, /)\n"
317"--\n"
318"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900319"Return True if the string is a digit string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900320"\n"
321"A string is a digit string if all characters in the string are digits and there\n"
322"is at least one character in the string.");
323
324#define UNICODE_ISDIGIT_METHODDEF \
325 {"isdigit", (PyCFunction)unicode_isdigit, METH_NOARGS, unicode_isdigit__doc__},
326
327static PyObject *
328unicode_isdigit_impl(PyObject *self);
329
330static PyObject *
331unicode_isdigit(PyObject *self, PyObject *Py_UNUSED(ignored))
332{
333 return unicode_isdigit_impl(self);
334}
335
336PyDoc_STRVAR(unicode_isnumeric__doc__,
337"isnumeric($self, /)\n"
338"--\n"
339"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900340"Return True if the string is a numeric string, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900341"\n"
342"A string is numeric if all characters in the string are numeric and there is at\n"
343"least one character in the string.");
344
345#define UNICODE_ISNUMERIC_METHODDEF \
346 {"isnumeric", (PyCFunction)unicode_isnumeric, METH_NOARGS, unicode_isnumeric__doc__},
347
348static PyObject *
349unicode_isnumeric_impl(PyObject *self);
350
351static PyObject *
352unicode_isnumeric(PyObject *self, PyObject *Py_UNUSED(ignored))
353{
354 return unicode_isnumeric_impl(self);
355}
356
357PyDoc_STRVAR(unicode_isidentifier__doc__,
358"isidentifier($self, /)\n"
359"--\n"
360"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900361"Return True if the string is a valid Python identifier, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900362"\n"
363"Use keyword.iskeyword() to test for reserved identifiers such as \"def\" and\n"
364"\"class\".");
365
366#define UNICODE_ISIDENTIFIER_METHODDEF \
367 {"isidentifier", (PyCFunction)unicode_isidentifier, METH_NOARGS, unicode_isidentifier__doc__},
368
369static PyObject *
370unicode_isidentifier_impl(PyObject *self);
371
372static PyObject *
373unicode_isidentifier(PyObject *self, PyObject *Py_UNUSED(ignored))
374{
375 return unicode_isidentifier_impl(self);
376}
377
378PyDoc_STRVAR(unicode_isprintable__doc__,
379"isprintable($self, /)\n"
380"--\n"
381"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900382"Return True if the string is printable, False otherwise.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900383"\n"
384"A string is printable if all of its characters are considered printable in\n"
385"repr() or if it is empty.");
386
387#define UNICODE_ISPRINTABLE_METHODDEF \
388 {"isprintable", (PyCFunction)unicode_isprintable, METH_NOARGS, unicode_isprintable__doc__},
389
390static PyObject *
391unicode_isprintable_impl(PyObject *self);
392
393static PyObject *
394unicode_isprintable(PyObject *self, PyObject *Py_UNUSED(ignored))
395{
396 return unicode_isprintable_impl(self);
397}
398
399PyDoc_STRVAR(unicode_join__doc__,
400"join($self, iterable, /)\n"
401"--\n"
402"\n"
403"Concatenate any number of strings.\n"
404"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900405"The string whose method is called is inserted in between each given strings.\n"
INADA Naoki3ae20562017-01-16 20:41:20 +0900406"The result is returned as a new string.\n"
407"\n"
408"Example: \'.\'.join([\'ab\', \'pq\', \'rs\']) -> \'ab.pq.rs\'");
409
410#define UNICODE_JOIN_METHODDEF \
411 {"join", (PyCFunction)unicode_join, METH_O, unicode_join__doc__},
412
413PyDoc_STRVAR(unicode_ljust__doc__,
414"ljust($self, width, fillchar=\' \', /)\n"
415"--\n"
416"\n"
417"Return a left-justified string of length width.\n"
418"\n"
419"Padding is done using the specified fill character (default is a space).");
420
421#define UNICODE_LJUST_METHODDEF \
422 {"ljust", (PyCFunction)unicode_ljust, METH_VARARGS, unicode_ljust__doc__},
423
424static PyObject *
425unicode_ljust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar);
426
427static PyObject *
428unicode_ljust(PyObject *self, PyObject *args)
429{
430 PyObject *return_value = NULL;
431 Py_ssize_t width;
432 Py_UCS4 fillchar = ' ';
433
434 if (!PyArg_ParseTuple(args, "n|O&:ljust",
435 &width, convert_uc, &fillchar)) {
436 goto exit;
437 }
438 return_value = unicode_ljust_impl(self, width, fillchar);
439
440exit:
441 return return_value;
442}
443
444PyDoc_STRVAR(unicode_lower__doc__,
445"lower($self, /)\n"
446"--\n"
447"\n"
448"Return a copy of the string converted to lowercase.");
449
450#define UNICODE_LOWER_METHODDEF \
451 {"lower", (PyCFunction)unicode_lower, METH_NOARGS, unicode_lower__doc__},
452
453static PyObject *
454unicode_lower_impl(PyObject *self);
455
456static PyObject *
457unicode_lower(PyObject *self, PyObject *Py_UNUSED(ignored))
458{
459 return unicode_lower_impl(self);
460}
461
462PyDoc_STRVAR(unicode_strip__doc__,
463"strip($self, chars=None, /)\n"
464"--\n"
465"\n"
466"Return a copy of the string with leading and trailing whitespace removed.\n"
467"\n"
468"If chars is given and not None, remove characters in chars instead.");
469
470#define UNICODE_STRIP_METHODDEF \
471 {"strip", (PyCFunction)unicode_strip, METH_VARARGS, unicode_strip__doc__},
472
473static PyObject *
474unicode_strip_impl(PyObject *self, PyObject *chars);
475
476static PyObject *
477unicode_strip(PyObject *self, PyObject *args)
478{
479 PyObject *return_value = NULL;
480 PyObject *chars = Py_None;
481
482 if (!PyArg_UnpackTuple(args, "strip",
483 0, 1,
484 &chars)) {
485 goto exit;
486 }
487 return_value = unicode_strip_impl(self, chars);
488
489exit:
490 return return_value;
491}
492
493PyDoc_STRVAR(unicode_lstrip__doc__,
494"lstrip($self, chars=None, /)\n"
495"--\n"
496"\n"
497"Return a copy of the string with leading whitespace removed.\n"
498"\n"
499"If chars is given and not None, remove characters in chars instead.");
500
501#define UNICODE_LSTRIP_METHODDEF \
502 {"lstrip", (PyCFunction)unicode_lstrip, METH_VARARGS, unicode_lstrip__doc__},
503
504static PyObject *
505unicode_lstrip_impl(PyObject *self, PyObject *chars);
506
507static PyObject *
508unicode_lstrip(PyObject *self, PyObject *args)
509{
510 PyObject *return_value = NULL;
511 PyObject *chars = NULL;
512
513 if (!PyArg_UnpackTuple(args, "lstrip",
514 0, 1,
515 &chars)) {
516 goto exit;
517 }
518 return_value = unicode_lstrip_impl(self, chars);
519
520exit:
521 return return_value;
522}
523
524PyDoc_STRVAR(unicode_rstrip__doc__,
525"rstrip($self, chars=None, /)\n"
526"--\n"
527"\n"
528"Return a copy of the string with trailing whitespace removed.\n"
529"\n"
530"If chars is given and not None, remove characters in chars instead.");
531
532#define UNICODE_RSTRIP_METHODDEF \
533 {"rstrip", (PyCFunction)unicode_rstrip, METH_VARARGS, unicode_rstrip__doc__},
534
535static PyObject *
536unicode_rstrip_impl(PyObject *self, PyObject *chars);
537
538static PyObject *
539unicode_rstrip(PyObject *self, PyObject *args)
540{
541 PyObject *return_value = NULL;
542 PyObject *chars = NULL;
543
544 if (!PyArg_UnpackTuple(args, "rstrip",
545 0, 1,
546 &chars)) {
547 goto exit;
548 }
549 return_value = unicode_rstrip_impl(self, chars);
550
551exit:
552 return return_value;
553}
554
555PyDoc_STRVAR(unicode_replace__doc__,
556"replace($self, old, new, count=-1, /)\n"
557"--\n"
558"\n"
559"Return a copy with all occurrences of substring old replaced by new.\n"
560"\n"
561" count\n"
562" Maximum number of occurrences to replace.\n"
563" -1 (the default value) means replace all occurrences.\n"
564"\n"
565"If the optional argument count is given, only the first count occurrences are\n"
566"replaced.");
567
568#define UNICODE_REPLACE_METHODDEF \
569 {"replace", (PyCFunction)unicode_replace, METH_VARARGS, unicode_replace__doc__},
570
571static PyObject *
572unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new,
573 Py_ssize_t count);
574
575static PyObject *
576unicode_replace(PyObject *self, PyObject *args)
577{
578 PyObject *return_value = NULL;
579 PyObject *old;
580 PyObject *new;
581 Py_ssize_t count = -1;
582
583 if (!PyArg_ParseTuple(args, "UU|n:replace",
584 &old, &new, &count)) {
585 goto exit;
586 }
587 return_value = unicode_replace_impl(self, old, new, count);
588
589exit:
590 return return_value;
591}
592
593PyDoc_STRVAR(unicode_rjust__doc__,
594"rjust($self, width, fillchar=\' \', /)\n"
595"--\n"
596"\n"
597"Return a right-justified string of length width.\n"
598"\n"
599"Padding is done using the specified fill character (default is a space).");
600
601#define UNICODE_RJUST_METHODDEF \
602 {"rjust", (PyCFunction)unicode_rjust, METH_VARARGS, unicode_rjust__doc__},
603
604static PyObject *
605unicode_rjust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar);
606
607static PyObject *
608unicode_rjust(PyObject *self, PyObject *args)
609{
610 PyObject *return_value = NULL;
611 Py_ssize_t width;
612 Py_UCS4 fillchar = ' ';
613
614 if (!PyArg_ParseTuple(args, "n|O&:rjust",
615 &width, convert_uc, &fillchar)) {
616 goto exit;
617 }
618 return_value = unicode_rjust_impl(self, width, fillchar);
619
620exit:
621 return return_value;
622}
623
624PyDoc_STRVAR(unicode_split__doc__,
625"split($self, /, sep=None, maxsplit=-1)\n"
626"--\n"
627"\n"
628"Return a list of the words in the string, using sep as the delimiter string.\n"
629"\n"
630" sep\n"
631" The delimiter according which to split the string.\n"
632" None (the default value) means split according to any whitespace,\n"
633" and discard empty strings from the result.\n"
634" maxsplit\n"
635" Maximum number of splits to do.\n"
636" -1 (the default value) means no limit.");
637
638#define UNICODE_SPLIT_METHODDEF \
639 {"split", (PyCFunction)unicode_split, METH_FASTCALL, unicode_split__doc__},
640
641static PyObject *
642unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit);
643
644static PyObject *
645unicode_split(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
646{
647 PyObject *return_value = NULL;
648 static const char * const _keywords[] = {"sep", "maxsplit", NULL};
649 static _PyArg_Parser _parser = {"|On:split", _keywords, 0};
650 PyObject *sep = Py_None;
651 Py_ssize_t maxsplit = -1;
652
653 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
654 &sep, &maxsplit)) {
655 goto exit;
656 }
657 return_value = unicode_split_impl(self, sep, maxsplit);
658
659exit:
660 return return_value;
661}
662
663PyDoc_STRVAR(unicode_partition__doc__,
664"partition($self, sep, /)\n"
665"--\n"
666"\n"
667"Partition the string into three parts using the given separator.\n"
668"\n"
669"This will search for the separator in the string. If the separator is found,\n"
670"returns a 3-tuple containing the part before the separator, the separator\n"
671"itself, and the part after it.\n"
672"\n"
673"If the separator is not found, returns a 3-tuple containing the original string\n"
674"and two empty strings.");
675
676#define UNICODE_PARTITION_METHODDEF \
677 {"partition", (PyCFunction)unicode_partition, METH_O, unicode_partition__doc__},
678
679PyDoc_STRVAR(unicode_rpartition__doc__,
680"rpartition($self, sep, /)\n"
681"--\n"
682"\n"
683"Partition the string into three parts using the given separator.\n"
684"\n"
685"This will search for the separator in the string, starting and the end. If\n"
686"the separator is found, returns a 3-tuple containing the part before the\n"
687"separator, the separator itself, and the part after it.\n"
688"\n"
689"If the separator is not found, returns a 3-tuple containing two empty strings\n"
690"and the original string.");
691
692#define UNICODE_RPARTITION_METHODDEF \
693 {"rpartition", (PyCFunction)unicode_rpartition, METH_O, unicode_rpartition__doc__},
694
695PyDoc_STRVAR(unicode_rsplit__doc__,
696"rsplit($self, /, sep=None, maxsplit=-1)\n"
697"--\n"
698"\n"
699"Return a list of the words in the string, using sep as the delimiter string.\n"
700"\n"
701" sep\n"
702" The delimiter according which to split the string.\n"
703" None (the default value) means split according to any whitespace,\n"
704" and discard empty strings from the result.\n"
705" maxsplit\n"
706" Maximum number of splits to do.\n"
707" -1 (the default value) means no limit.\n"
708"\n"
709"Splits are done starting at the end of the string and working to the front.");
710
711#define UNICODE_RSPLIT_METHODDEF \
712 {"rsplit", (PyCFunction)unicode_rsplit, METH_FASTCALL, unicode_rsplit__doc__},
713
714static PyObject *
715unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit);
716
717static PyObject *
718unicode_rsplit(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
719{
720 PyObject *return_value = NULL;
721 static const char * const _keywords[] = {"sep", "maxsplit", NULL};
722 static _PyArg_Parser _parser = {"|On:rsplit", _keywords, 0};
723 PyObject *sep = Py_None;
724 Py_ssize_t maxsplit = -1;
725
726 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
727 &sep, &maxsplit)) {
728 goto exit;
729 }
730 return_value = unicode_rsplit_impl(self, sep, maxsplit);
731
732exit:
733 return return_value;
734}
735
736PyDoc_STRVAR(unicode_splitlines__doc__,
737"splitlines($self, /, keepends=False)\n"
738"--\n"
739"\n"
740"Return a list of the lines in the string, breaking at line boundaries.\n"
741"\n"
742"Line breaks are not included in the resulting list unless keepends is given and\n"
743"true.");
744
745#define UNICODE_SPLITLINES_METHODDEF \
746 {"splitlines", (PyCFunction)unicode_splitlines, METH_FASTCALL, unicode_splitlines__doc__},
747
748static PyObject *
749unicode_splitlines_impl(PyObject *self, int keepends);
750
751static PyObject *
752unicode_splitlines(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
753{
754 PyObject *return_value = NULL;
755 static const char * const _keywords[] = {"keepends", NULL};
756 static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0};
757 int keepends = 0;
758
759 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
760 &keepends)) {
761 goto exit;
762 }
763 return_value = unicode_splitlines_impl(self, keepends);
764
765exit:
766 return return_value;
767}
768
769PyDoc_STRVAR(unicode_swapcase__doc__,
770"swapcase($self, /)\n"
771"--\n"
772"\n"
773"Convert uppercase characters to lowercase and lowercase characters to uppercase.");
774
775#define UNICODE_SWAPCASE_METHODDEF \
776 {"swapcase", (PyCFunction)unicode_swapcase, METH_NOARGS, unicode_swapcase__doc__},
777
778static PyObject *
779unicode_swapcase_impl(PyObject *self);
780
781static PyObject *
782unicode_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored))
783{
784 return unicode_swapcase_impl(self);
785}
786
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300787PyDoc_STRVAR(unicode_maketrans__doc__,
788"maketrans(x, y=None, z=None, /)\n"
789"--\n"
790"\n"
791"Return a translation table usable for str.translate().\n"
792"\n"
793"If there is only one argument, it must be a dictionary mapping Unicode\n"
794"ordinals (integers) or characters to Unicode ordinals, strings or None.\n"
795"Character keys will be then converted to ordinals.\n"
796"If there are two arguments, they must be strings of equal length, and\n"
797"in the resulting dictionary, each character in x will be mapped to the\n"
798"character at the same position in y. If there is a third argument, it\n"
799"must be a string, whose characters will be mapped to None in the result.");
800
801#define UNICODE_MAKETRANS_METHODDEF \
802 {"maketrans", (PyCFunction)unicode_maketrans, METH_VARARGS|METH_STATIC, unicode_maketrans__doc__},
803
804static PyObject *
805unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z);
806
807static PyObject *
808unicode_maketrans(void *null, PyObject *args)
809{
810 PyObject *return_value = NULL;
811 PyObject *x;
812 PyObject *y = NULL;
813 PyObject *z = NULL;
814
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300815 if (!PyArg_ParseTuple(args, "O|UU:maketrans",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300816 &x, &y, &z)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300817 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300818 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300819 return_value = unicode_maketrans_impl(x, y, z);
820
821exit:
822 return return_value;
823}
INADA Naoki3ae20562017-01-16 20:41:20 +0900824
825PyDoc_STRVAR(unicode_translate__doc__,
826"translate($self, table, /)\n"
827"--\n"
828"\n"
829"Replace each character in the string using the given translation table.\n"
830"\n"
831" table\n"
832" Translation table, which must be a mapping of Unicode ordinals to\n"
833" Unicode ordinals, strings, or None.\n"
834"\n"
835"The table must implement lookup/indexing via __getitem__, for instance a\n"
836"dictionary or list. If this operation raises LookupError, the character is\n"
837"left untouched. Characters mapped to None are deleted.");
838
839#define UNICODE_TRANSLATE_METHODDEF \
840 {"translate", (PyCFunction)unicode_translate, METH_O, unicode_translate__doc__},
841
842PyDoc_STRVAR(unicode_upper__doc__,
843"upper($self, /)\n"
844"--\n"
845"\n"
846"Return a copy of the string converted to uppercase.");
847
848#define UNICODE_UPPER_METHODDEF \
849 {"upper", (PyCFunction)unicode_upper, METH_NOARGS, unicode_upper__doc__},
850
851static PyObject *
852unicode_upper_impl(PyObject *self);
853
854static PyObject *
855unicode_upper(PyObject *self, PyObject *Py_UNUSED(ignored))
856{
857 return unicode_upper_impl(self);
858}
859
860PyDoc_STRVAR(unicode_zfill__doc__,
861"zfill($self, width, /)\n"
862"--\n"
863"\n"
864"Pad a numeric string with zeros on the left, to fill a field of the given width.\n"
865"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900866"The string is never truncated.");
INADA Naoki3ae20562017-01-16 20:41:20 +0900867
868#define UNICODE_ZFILL_METHODDEF \
869 {"zfill", (PyCFunction)unicode_zfill, METH_O, unicode_zfill__doc__},
870
871static PyObject *
872unicode_zfill_impl(PyObject *self, Py_ssize_t width);
873
874static PyObject *
875unicode_zfill(PyObject *self, PyObject *arg)
876{
877 PyObject *return_value = NULL;
878 Py_ssize_t width;
879
880 if (!PyArg_Parse(arg, "n:zfill", &width)) {
881 goto exit;
882 }
883 return_value = unicode_zfill_impl(self, width);
884
885exit:
886 return return_value;
887}
888
889PyDoc_STRVAR(unicode___format____doc__,
890"__format__($self, format_spec, /)\n"
891"--\n"
892"\n"
INADA Naoki15f94592017-01-16 21:49:13 +0900893"Return a formatted version of the string as described by format_spec.");
INADA Naoki3ae20562017-01-16 20:41:20 +0900894
895#define UNICODE___FORMAT___METHODDEF \
896 {"__format__", (PyCFunction)unicode___format__, METH_O, unicode___format____doc__},
897
898static PyObject *
899unicode___format___impl(PyObject *self, PyObject *format_spec);
900
901static PyObject *
902unicode___format__(PyObject *self, PyObject *arg)
903{
904 PyObject *return_value = NULL;
905 PyObject *format_spec;
906
907 if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
908 goto exit;
909 }
910 return_value = unicode___format___impl(self, format_spec);
911
912exit:
913 return return_value;
914}
915
916PyDoc_STRVAR(unicode_sizeof__doc__,
917"__sizeof__($self, /)\n"
918"--\n"
919"\n"
920"Return the size of the string in memory, in bytes.");
921
922#define UNICODE_SIZEOF_METHODDEF \
923 {"__sizeof__", (PyCFunction)unicode_sizeof, METH_NOARGS, unicode_sizeof__doc__},
924
925static PyObject *
926unicode_sizeof_impl(PyObject *self);
927
928static PyObject *
929unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
930{
931 return unicode_sizeof_impl(self);
932}
INADA Naoki15f94592017-01-16 21:49:13 +0900933/*[clinic end generated code: output=3b9b1e1f71ba3b00 input=a9049054013a1b77]*/