Lines Matching defs:str
73 class str "PyObject *" "&PyUnicode_Type"
712 backslashreplace(_PyBytesWriter *writer, char *str,
746 str = _PyBytesWriter_Prepare(writer, str, size);
747 if (str == NULL)
753 *str++ = '\\';
755 *str++ = 'U';
756 *str++ = Py_hexdigits[(ch>>28)&0xf];
757 *str++ = Py_hexdigits[(ch>>24)&0xf];
758 *str++ = Py_hexdigits[(ch>>20)&0xf];
759 *str++ = Py_hexdigits[(ch>>16)&0xf];
760 *str++ = Py_hexdigits[(ch>>12)&0xf];
761 *str++ = Py_hexdigits[(ch>>8)&0xf];
764 *str++ = 'u';
765 *str++ = Py_hexdigits[(ch>>12)&0xf];
766 *str++ = Py_hexdigits[(ch>>8)&0xf];
769 *str++ = 'x';
770 *str++ = Py_hexdigits[(ch>>4)&0xf];
771 *str++ = Py_hexdigits[ch&0xf];
773 return str;
779 xmlcharrefreplace(_PyBytesWriter *writer, char *str,
821 str = _PyBytesWriter_Prepare(writer, str, size);
822 if (str == NULL)
827 size = sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
831 str += size;
833 return str;
907 "must be str, not %.100s",
1004 _PyUnicode_CheckConsistency(str, 1) detects invalid characters, at least for
1255 * the caller fails before initializing str -- unicode_resize()
1256 * reads str[0], and the Keep-Alive optimization can keep memory
1257 * allocated for str alive across a call to unicode_dealloc(unicode).
1791 representation (the str field) has been set yet aka strings
2065 const char *str, Py_ssize_t len)
2069 const char *end = str + len;
2077 (const Py_UCS1*)str,
2078 (const Py_UCS1*)str + len);
2082 memcpy((char *) data + index, str, len);
2089 for (; str < end; ++ucs2, ++str)
2090 *ucs2 = (Py_UCS2)*str;
2099 for (; str < end; ++ucs4, ++str)
2100 *ucs4 = (Py_UCS4)*str;
2720 unicode_fromformat_write_str(_PyUnicodeWriter *writer, PyObject *str,
2726 if (PyUnicode_READY(str) == -1)
2729 length = PyUnicode_GET_LENGTH(str);
2732 return _PyUnicodeWriter_WriteStr(writer, str);
2738 if (PyUnicode_MAX_CHAR_VALUE(str) > writer->maxchar)
2739 maxchar = _PyUnicode_FindMaxChar(str, 0, length);
2754 str, 0, length);
2760 unicode_fromformat_write_cstr(_PyUnicodeWriter *writer, const char *str,
2769 length = strlen(str);
2773 while (length < precision && str[length]) {
2777 unicode = PyUnicode_DecodeUTF8Stateful(str, length, "replace", NULL);
3001 const char *str = va_arg(*vargs, const char *);
3008 assert(str != NULL);
3009 if (unicode_fromformat_write_cstr(writer, str, width, precision) < 0)
3018 PyObject *str;
3020 str = PyObject_Str(obj);
3021 if (!str)
3023 if (unicode_fromformat_write_str(writer, str, width, precision) == -1) {
3024 Py_DECREF(str);
3027 Py_DECREF(str);
3368 "argument must be str, not %.50s",
3404 "argument must be str or None, not %.50s",
3438 "Can't convert '%.100s' object to str implicitly",
3471 "decoding str is not supported");
3478 "decoding to str: need a bytes-like object, %.80s found",
3620 "'%.400s' decoder returned '%.400s' instead of 'str'; "
3647 "use PyCodec_Decode() to decode from str", 1) < 0)
3671 "use PyCodec_Decode() to decode from str to str", 1) < 0)
3683 "'%.400s' decoder returned '%.400s' instead of 'str'; "
3710 "use PyUnicode_AsEncodedString() to encode from str to bytes "
3744 char *str;
3747 int res = _Py_EncodeLocaleEx(wstr, &str, &error_pos, &reason,
3773 PyObject *bytes = PyBytes_FromString(str);
3774 PyMem_RawFree(str);
3933 "use PyCodec_Encode() to encode from str to str", 1) < 0)
3945 "'%.400s' encoder returned '%.400s' instead of 'str'; "
3959 unicode_decode_locale(const char *str, Py_ssize_t len,
3962 if (str[len] != '\0' || (size_t)len != strlen(str)) {
3970 int res = _Py_DecodeLocaleEx(str, &wstr, &wlen, &reason,
3976 "locale", str, len,
4000 PyUnicode_DecodeLocaleAndSize(const char *str, Py_ssize_t len,
4004 return unicode_decode_locale(str, len, error_handler, 1);
4008 PyUnicode_DecodeLocale(const char *str, const char *errors)
4010 Py_ssize_t size = (Py_ssize_t)strlen(str);
4012 return unicode_decode_locale(str, size, error_handler, 1);
4077 else { // PyOS_FSPath() guarantees its returned value is bytes or str.
4397 static const char *argparse = "Un;decoding error handler must return (str, int) tuple";
4510 static const char *argparse = "Un;decoding error handler must return (str, int) tuple";
4897 _PyUnicode_EncodeUTF7(PyObject *str,
4913 if (PyUnicode_READY(str) == -1)
4915 kind = PyUnicode_KIND(str);
4916 data = PyUnicode_DATA(str);
4917 len = PyUnicode_GET_LENGTH(str);
5395 PyMem_Free() to free the memory) into *str.
5403 _Py_EncodeUTF8Ex(const wchar_t *text, char **str, size_t *error_pos,
5522 *str = bytes2;
5802 _PyUnicode_EncodeUTF32(PyObject *str,
5822 if (!PyUnicode_Check(str)) {
5826 if (PyUnicode_READY(str) == -1)
5828 kind = PyUnicode_KIND(str);
5829 data = PyUnicode_DATA(str);
5830 len = PyUnicode_GET_LENGTH(str);
5878 str, &exc, pos, pos + 1, &newpos);
5886 str, pos, pos + 1,
5899 str, pos, pos + 1,
6123 _PyUnicode_EncodeUTF16(PyObject *str,
6144 if (!PyUnicode_Check(str)) {
6148 if (PyUnicode_READY(str) == -1)
6150 kind = PyUnicode_KIND(str);
6151 data = PyUnicode_DATA(str);
6152 len = PyUnicode_GET_LENGTH(str);
6217 str, &exc, pos, pos + 1, &newpos);
6225 str, pos, pos + 1,
6238 str, pos, pos + 1,
6997 static const char *argparse = "On;encoding error handler must return (str/bytes, int) tuple";
7057 char *str;
7078 str = _PyBytesWriter_Alloc(&writer, size);
7079 if (str == NULL)
7088 *str++ = (char)ch;
7114 memset(str, '?', collend - collstart);
7115 str += (collend - collstart);
7124 str = backslashreplace(&writer, str,
7126 if (str == NULL)
7134 str = xmlcharrefreplace(&writer, str,
7136 if (str == NULL)
7148 *str++ = (char)(ch - 0xdc00);
7166 str = _PyBytesWriter_Prepare(&writer, str,
7168 if (str == NULL)
7180 str = _PyBytesWriter_WriteBytes(&writer, str,
7200 str = _PyBytesWriter_WriteBytes(&writer, str,
7204 if (str == NULL)
7219 return _PyBytesWriter_Finish(&writer, str);
8295 "character mapping must return integer, None or str");
8933 static const char *argparse = "Un;translating error handler must return (str, int) tuple";
9022 "character mapping must return integer, None or str");
9311 PyUnicode_Translate(PyObject *str,
9315 if (ensure_unicode(str) < 0)
9317 return _PyUnicode_TranslateCharmap(str, mapping, errors);
9616 PyUnicode_Count(PyObject *str,
9626 if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0)
9629 kind1 = PyUnicode_KIND(str);
9634 len1 = PyUnicode_GET_LENGTH(str);
9640 buf1 = PyUnicode_DATA(str);
9650 if (PyUnicode_IS_ASCII(str) && PyUnicode_IS_ASCII(substr))
9690 PyUnicode_Find(PyObject *str,
9696 if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0)
9699 return any_find_slice(str, substr, start, end, direction);
9703 PyUnicode_FindChar(PyObject *str, Py_UCS4 ch,
9709 if (PyUnicode_READY(str) == -1)
9711 len = PyUnicode_GET_LENGTH(str);
9715 kind = PyUnicode_KIND(str);
9716 result = findchar(PyUnicode_1BYTE_DATA(str) + kind*start,
9792 PyUnicode_Tailmatch(PyObject *str,
9798 if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0)
9801 return tailmatch(str, substr, start, end, direction);
10106 "separator: expected str instance,"
10124 * of str in the sequence.
10139 "sequence item %zd: expected str instance,"
10886 str.title as unicode_title
10904 str.capitalize as unicode_capitalize
10924 str.casefold as unicode_casefold
10966 str.center as unicode_center
11171 PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str)
11176 const unsigned char *ustr = (const unsigned char *)str;
11191 return -1; /* str is longer */
11198 size_t len, len2 = strlen(str);
11202 cmp = memcmp(data, str, len);
11212 return -1; /* str is longer */
11218 for (i = 0; (chr = PyUnicode_READ(kind, data, i)) && str[i]; i++)
11219 if (chr != (unsigned char)str[i])
11220 return (chr < (unsigned char)(str[i])) ? -1 : 1;
11225 if (str[i])
11226 return -1; /* str is longer */
11232 non_ready_unicode_equal_to_ascii_string(PyObject *unicode, const char *str)
11237 if (strlen(str) != len)
11242 unsigned char c = (unsigned char)str[i];
11250 _PyUnicode_EqualToASCIIString(PyObject *unicode, const char *str)
11254 assert(str);
11256 for (const char *p = str; *p; p++) {
11263 return non_ready_unicode_equal_to_ascii_string(unicode, str);
11268 return strlen(str) == len &&
11269 memcmp(PyUnicode_1BYTE_DATA(unicode), str, len) == 0;
11362 PyUnicode_Contains(PyObject *str, PyObject *substr)
11377 if (ensure_unicode(str) < 0)
11380 kind1 = PyUnicode_KIND(str);
11384 len1 = PyUnicode_GET_LENGTH(str);
11388 buf1 = PyUnicode_DATA(str);
11436 "can only concatenate str (not \"%.200s\") to str",
11656 str.encode as unicode_encode
11658 encoding: str(c_default="NULL") = 'utf-8'
11660 errors: str(c_default="NULL") = 'strict'
11678 str.expandtabs as unicode_expandtabs
11881 str.isascii as unicode_isascii
11900 str.islower as unicode_islower
11945 str.isupper as unicode_isupper
11990 str.istitle as unicode_istitle
12048 str.isspace as unicode_isspace
12088 str.isalpha as unicode_isalpha
12127 str.isalnum as unicode_isalnum
12169 str.isdecimal as unicode_isdecimal
12208 str.isdigit as unicode_isdigit
12248 str.isnumeric as unicode_isnumeric
12377 str.isidentifier as unicode_isidentifier
12393 str.isprintable as unicode_isprintable
12429 str.join as unicode_join
12458 str.ljust as unicode_ljust
12483 str.lower as unicode_lower
12508 /* externally visible for str.strip(unicode) */
12670 "%s arg must be None or str",
12681 str.strip as unicode_strip
12700 str.lstrip as unicode_lstrip
12719 str.rstrip as unicode_rstrip
12738 unicode_repeat(PyObject *str, Py_ssize_t len)
12748 return unicode_result_unchanged(str);
12750 if (PyUnicode_READY(str) == -1)
12753 if (PyUnicode_GET_LENGTH(str) > PY_SSIZE_T_MAX / len) {
12758 nchars = len * PyUnicode_GET_LENGTH(str);
12760 u = PyUnicode_New(nchars, PyUnicode_MAX_CHAR_VALUE(str));
12763 assert(PyUnicode_KIND(u) == PyUnicode_KIND(str));
12765 if (PyUnicode_GET_LENGTH(str) == 1) {
12766 int kind = PyUnicode_KIND(str);
12767 Py_UCS4 fill_char = PyUnicode_READ(kind, PyUnicode_DATA(str), 0);
12784 Py_ssize_t char_size = PyUnicode_KIND(str);
12786 _PyBytes_Repeat(to, nchars * char_size, PyUnicode_DATA(str),
12787 PyUnicode_GET_LENGTH(str) * char_size);
12795 PyUnicode_Replace(PyObject *str,
12800 if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0 ||
12803 return replace(str, substr, replstr, maxcount);
12807 str.replace as unicode_replace
12833 str.removeprefix as unicode_removeprefix
12838 Return a str with the given prefix string removed if present.
12860 str.removesuffix as unicode_removesuffix
12865 Return a str with the given suffix string removed if present.
13122 str.rjust as unicode_rjust
13156 str.split as unicode_split
13170 Note, str.split() is mainly useful for data that has been intentionally
13186 "must be str or None, not %.100s",
13295 str.partition as unicode_partition
13318 str.rpartition as unicode_rpartition = str.partition
13347 str.rsplit as unicode_rsplit = str.split
13364 "must be str or None, not %.100s",
13370 str.splitlines as unicode_splitlines
13394 str.swapcase as unicode_swapcase
13411 str.maketrans as unicode_maketrans
13421 Return a translation table usable for str.translate().
13539 str.translate as unicode_translate
13561 str.upper as unicode_upper
13578 str.zfill as unicode_zfill
13651 "tuple for startswith must only contain str, "
13668 "startswith first arg must be str or "
13669 "a tuple of str, not %.100s", Py_TYPE(subobj)->tp_name);
13705 "tuple for endswith must only contain str, "
13721 "endswith first arg must be str or "
13722 "a tuple of str, not %.100s", Py_TYPE(subobj)->tp_name);
13894 _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str)
13899 if (PyUnicode_READY(str) == -1)
13901 len = PyUnicode_GET_LENGTH(str);
13904 maxchar = PyUnicode_MAX_CHAR_VALUE(str);
13907 assert(_PyUnicode_CheckConsistency(str, 1));
13909 Py_INCREF(str);
13910 writer->buffer = str;
13919 str, 0, len);
13925 _PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer, PyObject *str,
13931 if (PyUnicode_READY(str) == -1)
13935 assert(end <= PyUnicode_GET_LENGTH(str));
13941 if (start == 0 && end == PyUnicode_GET_LENGTH(str))
13942 return _PyUnicodeWriter_WriteStr(writer, str);
13944 if (PyUnicode_MAX_CHAR_VALUE(str) > writer->maxchar)
13945 maxchar = _PyUnicode_FindMaxChar(str, start, end);
13954 str, start, len);
13969 PyObject *str;
13971 str = _PyUnicode_FromASCII(ascii, len);
13972 if (str == NULL)
13976 writer->buffer = str;
13989 const Py_UCS1 *str = (const Py_UCS1 *)ascii;
13992 memcpy(data + writer->pos, str, len);
14021 const char *str, Py_ssize_t len)
14025 maxchar = ucs1lib_find_max_char((const Py_UCS1*)str, (const Py_UCS1*)str + len);
14028 unicode_write_cstr(writer->buffer, writer->pos, str, len);
14036 PyObject *str;
14043 str = writer->buffer;
14047 assert(PyUnicode_GET_LENGTH(str) == writer->pos);
14048 return str;
14051 if (PyUnicode_GET_LENGTH(str) != writer->pos) {
14053 str2 = resize_compact(str, writer->pos);
14055 Py_DECREF(str);
14058 str = str2;
14061 assert(_PyUnicode_CheckConsistency(str, 1));
14062 return unicode_result_ready(str);
14074 "S.format(*args, **kwargs) -> str\n\
14080 "S.format_map(mapping) -> str\n\
14086 str.__format__ as unicode___format__
14115 str.__sizeof__ as unicode_sizeof
14688 Return 0 if the argument has been formatted into arg->str.
14870 - "c": int or str (1 character)
14986 PyObject *str)
15003 if (PyUnicode_READY(str) == -1)
15006 len = PyUnicode_GET_LENGTH(str);
15012 if (_PyUnicodeWriter_WriteStr(writer, str) == -1)
15025 kind = PyUnicode_KIND(str);
15026 pbuf = PyUnicode_DATA(str);
15058 if (PyUnicode_MAX_CHAR_VALUE(str) > maxchar) {
15059 Py_UCS4 strmaxchar = _PyUnicode_FindMaxChar(str, 0, pindex+len);
15125 str, pindex, len);
15144 PyObject *str;
15159 str = NULL;
15165 ret = unicode_format_arg_format(ctx, &arg, &str);
15170 ret = unicode_format_arg_output(ctx, &arg, str);
15171 Py_DECREF(str);
15272 str.__new__ as unicode_new
15275 encoding: str = NULL
15276 errors: str = NULL
15402 "str(object='') -> str\n\
15403 str(bytes_or_buffer[, encoding[, errors]]) -> str\n\
15417 "str", /* tp_name */
15879 encode_wstr_utf8(wchar_t *wstr, char **str, const char *name)
15882 res = _Py_EncodeUTF8Ex(wstr, str, NULL, NULL, 1, _Py_ERROR_STRICT);