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