Lines Matching refs:self
82 def converter_init(self):
83 if self.default is not unspecified:
84 self.c_default = ascii(self.default)
85 if len(self.c_default) > 4 or self.c_default[0] != "'":
86 self.c_default = hex(ord(self.default))
8381 EncodingMap_size_impl(struct encoding_map *self)
8384 return PyLong_FromLong((sizeof(*self) - 1) + 16*self->count2 +
8385 128*self->count3);
9725 tailmatch(PyObject *self,
9739 if (PyUnicode_READY(self) == -1 ||
9743 ADJUST_INDICES(start, end, PyUnicode_GET_LENGTH(self));
9751 kind_self = PyUnicode_KIND(self);
9752 data_self = PyUnicode_DATA(self);
9805 ascii_upper_or_lower(PyObject *self, int lower)
9807 Py_ssize_t len = PyUnicode_GET_LENGTH(self);
9808 const char *data = PyUnicode_DATA(self);
9991 case_operation(PyObject *self,
10001 assert(PyUnicode_IS_READY(self));
10003 kind = PyUnicode_KIND(self);
10004 data = PyUnicode_DATA(self);
10005 length = PyUnicode_GET_LENGTH(self);
10284 pad(PyObject *self,
10300 return unicode_result_unchanged(self);
10302 if (left > PY_SSIZE_T_MAX - _PyUnicode_LENGTH(self) ||
10303 right > PY_SSIZE_T_MAX - (left + _PyUnicode_LENGTH(self))) {
10307 maxchar = PyUnicode_MAX_CHAR_VALUE(self);
10309 u = PyUnicode_New(left + _PyUnicode_LENGTH(self) + right, maxchar);
10318 unicode_fill(kind, data, fill, left + _PyUnicode_LENGTH(self), right);
10319 _PyUnicode_FastCopyCharacters(u, left, self, 0, _PyUnicode_LENGTH(self));
10360 split(PyObject *self,
10372 if (PyUnicode_READY(self) == -1)
10376 switch (PyUnicode_KIND(self)) {
10378 if (PyUnicode_IS_ASCII(self))
10380 self, PyUnicode_1BYTE_DATA(self),
10381 PyUnicode_GET_LENGTH(self), maxcount
10385 self, PyUnicode_1BYTE_DATA(self),
10386 PyUnicode_GET_LENGTH(self), maxcount
10390 self, PyUnicode_2BYTE_DATA(self),
10391 PyUnicode_GET_LENGTH(self), maxcount
10395 self, PyUnicode_4BYTE_DATA(self),
10396 PyUnicode_GET_LENGTH(self), maxcount
10405 kind1 = PyUnicode_KIND(self);
10407 len1 = PyUnicode_GET_LENGTH(self);
10413 Py_INCREF(self);
10414 PyList_SET_ITEM(out, 0, self);
10417 buf1 = PyUnicode_DATA(self);
10427 if (PyUnicode_IS_ASCII(self) && PyUnicode_IS_ASCII(substring))
10429 self, buf1, len1, buf2, len2, maxcount);
10432 self, buf1, len1, buf2, len2, maxcount);
10436 self, buf1, len1, buf2, len2, maxcount);
10440 self, buf1, len1, buf2, len2, maxcount);
10452 rsplit(PyObject *self,
10464 if (PyUnicode_READY(self) == -1)
10468 switch (PyUnicode_KIND(self)) {
10470 if (PyUnicode_IS_ASCII(self))
10472 self, PyUnicode_1BYTE_DATA(self),
10473 PyUnicode_GET_LENGTH(self), maxcount
10477 self, PyUnicode_1BYTE_DATA(self),
10478 PyUnicode_GET_LENGTH(self), maxcount
10482 self, PyUnicode_2BYTE_DATA(self),
10483 PyUnicode_GET_LENGTH(self), maxcount
10487 self, PyUnicode_4BYTE_DATA(self),
10488 PyUnicode_GET_LENGTH(self), maxcount
10497 kind1 = PyUnicode_KIND(self);
10499 len1 = PyUnicode_GET_LENGTH(self);
10505 Py_INCREF(self);
10506 PyList_SET_ITEM(out, 0, self);
10509 buf1 = PyUnicode_DATA(self);
10519 if (PyUnicode_IS_ASCII(self) && PyUnicode_IS_ASCII(substring))
10521 self, buf1, len1, buf2, len2, maxcount);
10524 self, buf1, len1, buf2, len2, maxcount);
10528 self, buf1, len1, buf2, len2, maxcount);
10532 self, buf1, len1, buf2, len2, maxcount);
10605 replace(PyObject *self, PyObject *str1,
10609 const char *sbuf = PyUnicode_DATA(self);
10613 int skind = PyUnicode_KIND(self);
10616 Py_ssize_t slen = PyUnicode_GET_LENGTH(self);
10633 maxchar = PyUnicode_MAX_CHAR_VALUE(self);
10662 _PyUnicode_FastCopyCharacters(u, 0, self, 0, slen);
10676 i = anylib_find(rkind, self, sbuf, slen, str1, buf1, len1, 0);
10686 /* widen self and buf1 */
10715 i = anylib_find(rkind, self,
10739 n = anylib_count(rkind, self, sbuf, slen, str1, buf1, len1, maxcount);
10749 /* widen self and buf1 */
10764 /* new_size = PyUnicode_GET_LENGTH(self) + n * (PyUnicode_GET_LENGTH(str2) -
10790 j = anylib_find(rkind, self,
10845 assert(srelease == (sbuf != PyUnicode_DATA(self)));
10859 assert(srelease == (sbuf != PyUnicode_DATA(self)));
10868 return unicode_result_unchanged(self);
10871 assert(srelease == (sbuf != PyUnicode_DATA(self)));
10895 unicode_title_impl(PyObject *self)
10898 if (PyUnicode_READY(self) == -1)
10900 return case_operation(self, do_title);
10913 unicode_capitalize_impl(PyObject *self)
10916 if (PyUnicode_READY(self) == -1)
10918 if (PyUnicode_GET_LENGTH(self) == 0)
10919 return unicode_result_unchanged(self);
10920 return case_operation(self, do_capitalize);
10930 unicode_casefold_impl(PyObject *self)
10933 if (PyUnicode_READY(self) == -1)
10935 if (PyUnicode_IS_ASCII(self))
10936 return ascii_upper_or_lower(self, 1);
10937 return case_operation(self, do_casefold);
10978 unicode_center_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar)
10983 if (PyUnicode_READY(self) == -1)
10986 if (PyUnicode_GET_LENGTH(self) >= width)
10987 return unicode_result_unchanged(self);
10989 marg = width - PyUnicode_GET_LENGTH(self);
10992 return pad(self, left, marg - left, fillchar);
11592 unicode_count(PyObject *self, PyObject *args)
11605 kind1 = PyUnicode_KIND(self);
11610 len1 = PyUnicode_GET_LENGTH(self);
11616 buf1 = PyUnicode_DATA(self);
11671 unicode_encode_impl(PyObject *self, const char *encoding, const char *errors)
11674 return PyUnicode_AsEncodedString(self, encoding, errors);
11688 unicode_expandtabs_impl(PyObject *self, int tabsize)
11699 if (PyUnicode_READY(self) == -1)
11703 src_len = PyUnicode_GET_LENGTH(self);
11705 kind = PyUnicode_KIND(self);
11706 src_data = PyUnicode_DATA(self);
11730 return unicode_result_unchanged(self);
11733 u = PyUnicode_New(j, PyUnicode_MAX_CHAR_VALUE(self));
11776 unicode_find(PyObject *self, PyObject *args)
11787 if (PyUnicode_READY(self) == -1)
11790 result = any_find_slice(self, substring, start, end, 1);
11799 unicode_getitem(PyObject *self, Py_ssize_t index)
11805 if (!PyUnicode_Check(self)) {
11809 if (PyUnicode_READY(self) == -1) {
11812 if (index < 0 || index >= PyUnicode_GET_LENGTH(self)) {
11816 kind = PyUnicode_KIND(self);
11817 data = PyUnicode_DATA(self);
11825 unicode_hash(PyObject *self)
11832 if (_PyUnicode_HASH(self) != -1)
11833 return _PyUnicode_HASH(self);
11834 if (PyUnicode_READY(self) == -1)
11837 x = _Py_HashBytes(PyUnicode_DATA(self),
11838 PyUnicode_GET_LENGTH(self) * PyUnicode_KIND(self));
11839 _PyUnicode_HASH(self) = x;
11853 unicode_index(PyObject *self, PyObject *args)
11864 if (PyUnicode_READY(self) == -1)
11867 result = any_find_slice(self, substring, start, end, 1);
11890 unicode_isascii_impl(PyObject *self)
11893 if (PyUnicode_READY(self) == -1) {
11896 return PyBool_FromLong(PyUnicode_IS_ASCII(self));
11909 unicode_islower_impl(PyObject *self)
11917 if (PyUnicode_READY(self) == -1)
11919 length = PyUnicode_GET_LENGTH(self);
11920 kind = PyUnicode_KIND(self);
11921 data = PyUnicode_DATA(self);
11954 unicode_isupper_impl(PyObject *self)
11962 if (PyUnicode_READY(self) == -1)
11964 length = PyUnicode_GET_LENGTH(self);
11965 kind = PyUnicode_KIND(self);
11966 data = PyUnicode_DATA(self);
11999 unicode_istitle_impl(PyObject *self)
12007 if (PyUnicode_READY(self) == -1)
12009 length = PyUnicode_GET_LENGTH(self);
12010 kind = PyUnicode_KIND(self);
12011 data = PyUnicode_DATA(self);
12057 unicode_isspace_impl(PyObject *self)
12064 if (PyUnicode_READY(self) == -1)
12066 length = PyUnicode_GET_LENGTH(self);
12067 kind = PyUnicode_KIND(self);
12068 data = PyUnicode_DATA(self);
12097 unicode_isalpha_impl(PyObject *self)
12104 if (PyUnicode_READY(self) == -1)
12106 length = PyUnicode_GET_LENGTH(self);
12107 kind = PyUnicode_KIND(self);
12108 data = PyUnicode_DATA(self);
12136 unicode_isalnum_impl(PyObject *self)
12143 if (PyUnicode_READY(self) == -1)
12146 kind = PyUnicode_KIND(self);
12147 data = PyUnicode_DATA(self);
12148 len = PyUnicode_GET_LENGTH(self);
12178 unicode_isdecimal_impl(PyObject *self)
12185 if (PyUnicode_READY(self) == -1)
12187 length = PyUnicode_GET_LENGTH(self);
12188 kind = PyUnicode_KIND(self);
12189 data = PyUnicode_DATA(self);
12217 unicode_isdigit_impl(PyObject *self)
12224 if (PyUnicode_READY(self) == -1)
12226 length = PyUnicode_GET_LENGTH(self);
12227 kind = PyUnicode_KIND(self);
12228 data = PyUnicode_DATA(self);
12257 unicode_isnumeric_impl(PyObject *self)
12264 if (PyUnicode_READY(self) == -1)
12266 length = PyUnicode_GET_LENGTH(self);
12267 kind = PyUnicode_KIND(self);
12268 data = PyUnicode_DATA(self);
12287 _PyUnicode_ScanIdentifier(PyObject *self)
12290 if (PyUnicode_READY(self) == -1)
12293 Py_ssize_t len = PyUnicode_GET_LENGTH(self);
12299 int kind = PyUnicode_KIND(self);
12300 const void *data = PyUnicode_DATA(self);
12324 PyUnicode_IsIdentifier(PyObject *self)
12326 if (PyUnicode_IS_READY(self)) {
12327 Py_ssize_t i = _PyUnicode_ScanIdentifier(self);
12328 Py_ssize_t len = PyUnicode_GET_LENGTH(self);
12335 Py_ssize_t i = 0, len = PyUnicode_GET_SIZE(self);
12341 const wchar_t *wstr = _PyUnicode_WSTR(self);
12386 unicode_isidentifier_impl(PyObject *self)
12389 return PyBool_FromLong(PyUnicode_IsIdentifier(self));
12402 unicode_isprintable_impl(PyObject *self)
12409 if (PyUnicode_READY(self) == -1)
12411 length = PyUnicode_GET_LENGTH(self);
12412 kind = PyUnicode_KIND(self);
12413 data = PyUnicode_DATA(self);
12443 unicode_join(PyObject *self, PyObject *iterable)
12446 return PyUnicode_Join(self, iterable);
12450 unicode_length(PyObject *self)
12452 if (PyUnicode_READY(self) == -1)
12454 return PyUnicode_GET_LENGTH(self);
12470 unicode_ljust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar)
12473 if (PyUnicode_READY(self) == -1)
12476 if (PyUnicode_GET_LENGTH(self) >= width)
12477 return unicode_result_unchanged(self);
12479 return pad(self, 0, width - PyUnicode_GET_LENGTH(self), fillchar);
12489 unicode_lower_impl(PyObject *self)
12492 if (PyUnicode_READY(self) == -1)
12494 if (PyUnicode_IS_ASCII(self))
12495 return ascii_upper_or_lower(self, 1);
12496 return case_operation(self, do_lower);
12510 _PyUnicode_XStrip(PyObject *self, int striptype, PyObject *sepobj)
12518 if (PyUnicode_READY(self) == -1 || PyUnicode_READY(sepobj) == -1)
12521 kind = PyUnicode_KIND(self);
12522 data = PyUnicode_DATA(self);
12523 len = PyUnicode_GET_LENGTH(self);
12556 return PyUnicode_Substring(self, i, j);
12560 PyUnicode_Substring(PyObject *self, Py_ssize_t start, Py_ssize_t end)
12566 if (PyUnicode_READY(self) == -1)
12569 length = PyUnicode_GET_LENGTH(self);
12573 return unicode_result_unchanged(self);
12583 if (PyUnicode_IS_ASCII(self)) {
12584 data = PyUnicode_1BYTE_DATA(self);
12588 kind = PyUnicode_KIND(self);
12589 data = PyUnicode_1BYTE_DATA(self);
12597 do_strip(PyObject *self, int striptype)
12601 if (PyUnicode_READY(self) == -1)
12604 len = PyUnicode_GET_LENGTH(self);
12606 if (PyUnicode_IS_ASCII(self)) {
12607 const Py_UCS1 *data = PyUnicode_1BYTE_DATA(self);
12632 int kind = PyUnicode_KIND(self);
12633 const void *data = PyUnicode_DATA(self);
12658 return PyUnicode_Substring(self, i, j);
12663 do_argstrip(PyObject *self, int striptype, PyObject *sep)
12667 return _PyUnicode_XStrip(self, striptype, sep);
12676 return do_strip(self, striptype);
12692 unicode_strip_impl(PyObject *self, PyObject *chars)
12695 return do_argstrip(self, BOTHSTRIP, chars);
12711 unicode_lstrip_impl(PyObject *self, PyObject *chars)
12714 return do_argstrip(self, LEFTSTRIP, chars);
12730 unicode_rstrip_impl(PyObject *self, PyObject *chars)
12733 return do_argstrip(self, RIGHTSTRIP, chars);
12823 unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new,
12827 if (PyUnicode_READY(self) == -1)
12829 return replace(self, old, new, count);
12845 unicode_removeprefix_impl(PyObject *self, PyObject *prefix)
12848 int match = tailmatch(self, prefix, 0, PY_SSIZE_T_MAX, -1);
12853 return PyUnicode_Substring(self, PyUnicode_GET_LENGTH(prefix),
12854 PyUnicode_GET_LENGTH(self));
12856 return unicode_result_unchanged(self);
12873 unicode_removesuffix_impl(PyObject *self, PyObject *suffix)
12876 int match = tailmatch(self, suffix, 0, PY_SSIZE_T_MAX, +1);
12881 return PyUnicode_Substring(self, 0, PyUnicode_GET_LENGTH(self)
12884 return unicode_result_unchanged(self);
13062 unicode_rfind(PyObject *self, PyObject *args)
13073 if (PyUnicode_READY(self) == -1)
13076 result = any_find_slice(self, substring, start, end, -1);
13094 unicode_rindex(PyObject *self, PyObject *args)
13105 if (PyUnicode_READY(self) == -1)
13108 result = any_find_slice(self, substring, start, end, -1);
13134 unicode_rjust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar)
13137 if (PyUnicode_READY(self) == -1)
13140 if (PyUnicode_GET_LENGTH(self) >= width)
13141 return unicode_result_unchanged(self);
13143 return pad(self, width - PyUnicode_GET_LENGTH(self), 0, fillchar);
13177 unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
13181 return split(self, NULL, maxsplit);
13183 return split(self, sep, maxsplit);
13311 unicode_partition(PyObject *self, PyObject *sep)
13314 return PyUnicode_Partition(self, sep);
13331 unicode_rpartition(PyObject *self, PyObject *sep)
13334 return PyUnicode_RPartition(self, sep);
13355 unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
13359 return rsplit(self, NULL, maxsplit);
13361 return rsplit(self, sep, maxsplit);
13381 unicode_splitlines_impl(PyObject *self, int keepends)
13384 return PyUnicode_Splitlines(self, keepends);
13388 PyObject *unicode_str(PyObject *self)
13390 return unicode_result_unchanged(self);
13400 unicode_swapcase_impl(PyObject *self)
13403 if (PyUnicode_READY(self) == -1)
13405 return case_operation(self, do_swapcase);
13554 unicode_translate(PyObject *self, PyObject *table)
13557 return _PyUnicode_TranslateCharmap(self, table, "ignore");
13567 unicode_upper_impl(PyObject *self)
13570 if (PyUnicode_READY(self) == -1)
13572 if (PyUnicode_IS_ASCII(self))
13573 return ascii_upper_or_lower(self, 0);
13574 return case_operation(self, do_upper);
13589 unicode_zfill_impl(PyObject *self, Py_ssize_t width)
13598 if (PyUnicode_READY(self) == -1)
13601 if (PyUnicode_GET_LENGTH(self) >= width)
13602 return unicode_result_unchanged(self);
13604 fill = width - PyUnicode_GET_LENGTH(self);
13606 u = pad(self, fill, 0, '0');
13634 unicode_startswith(PyObject *self,
13656 result = tailmatch(self, substring, start, end, -1);
13672 result = tailmatch(self, subobj, start, end, -1);
13688 unicode_endswith(PyObject *self,
13710 result = tailmatch(self, substring, start, end, +1);
13725 result = tailmatch(self, subobj, start, end, +1);
14095 unicode___format___impl(PyObject *self, PyObject *format_spec)
14101 if (PyUnicode_READY(self) == -1)
14105 self, format_spec, 0,
14121 unicode_sizeof_impl(PyObject *self)
14128 if (PyUnicode_IS_COMPACT_ASCII(self))
14129 size = sizeof(PyASCIIObject) + PyUnicode_GET_LENGTH(self) + 1;
14130 else if (PyUnicode_IS_COMPACT(self))
14132 (PyUnicode_GET_LENGTH(self) + 1) * PyUnicode_KIND(self);
14137 if (_PyUnicode_DATA_ANY(self))
14138 size += (PyUnicode_GET_LENGTH(self) + 1) *
14139 PyUnicode_KIND(self);
14143 if (_PyUnicode_HAS_WSTR_MEMORY(self))
14144 size += (PyUnicode_WSTR_LENGTH(self) + 1) * sizeof(wchar_t);
14145 if (_PyUnicode_HAS_UTF8_MEMORY(self))
14146 size += PyUnicode_UTF8_LENGTH(self) + 1;
14241 unicode_subscript(PyObject* self, PyObject* item)
14243 if (PyUnicode_READY(self) == -1)
14251 i += PyUnicode_GET_LENGTH(self);
14252 return unicode_getitem(self, i);
14265 slicelength = PySlice_AdjustIndices(PyUnicode_GET_LENGTH(self),
14271 slicelength == PyUnicode_GET_LENGTH(self)) {
14272 return unicode_result_unchanged(self);
14274 return PyUnicode_Substring(self,
14278 src_kind = PyUnicode_KIND(self);
14279 src_data = PyUnicode_DATA(self);
14280 if (!PyUnicode_IS_ASCII(self)) {
15305 PyObject *self;
15317 self = type->tp_alloc(type, 0);
15318 if (self == NULL) {
15324 _PyUnicode_LENGTH(self) = length;
15326 _PyUnicode_HASH(self) = -1;
15328 _PyUnicode_HASH(self) = _PyUnicode_HASH(unicode);
15330 _PyUnicode_STATE(self).interned = 0;
15331 _PyUnicode_STATE(self).kind = kind;
15332 _PyUnicode_STATE(self).compact = 0;
15333 _PyUnicode_STATE(self).ascii = _PyUnicode_STATE(unicode).ascii;
15334 _PyUnicode_STATE(self).ready = 1;
15335 _PyUnicode_WSTR(self) = NULL;
15336 _PyUnicode_UTF8_LENGTH(self) = 0;
15337 _PyUnicode_UTF8(self) = NULL;
15338 _PyUnicode_WSTR_LENGTH(self) = 0;
15339 _PyUnicode_DATA_ANY(self) = NULL;
15371 _PyUnicode_DATA_ANY(self) = data;
15373 _PyUnicode_UTF8_LENGTH(self) = length;
15374 _PyUnicode_UTF8(self) = data;
15377 _PyUnicode_WSTR_LENGTH(self) = length;
15378 _PyUnicode_WSTR(self) = (wchar_t *)data;
15383 assert(_PyUnicode_CheckConsistency(self, 1));
15385 _PyUnicode_HASH(self) = _PyUnicode_HASH(unicode);
15387 return self;
15390 Py_DECREF(self);