annotate Include/stringobject.h @ 51330:ca423008fa4a legacy-trunk

#5144: document that PySys_SetArgv prepends the script directory (or the empty string) to sys.path.
author Georg Brandl <georg@python.org>
date Thu, 05 Feb 2009 10:37:07 +0000
parents 752e1abaf15a
children e38335d4df91 c5e0d9beebf9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47578
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
1
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
2 /* String (str/bytes) object interface */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
3
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
4 #ifndef Py_STRINGOBJECT_H
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
5 #define Py_STRINGOBJECT_H
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
6 #ifdef __cplusplus
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
7 extern "C" {
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
8 #endif
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
9
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
10 #include <stdarg.h>
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
11
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
12 /*
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
13 Type PyStringObject represents a character string. An extra zero byte is
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
14 reserved at the end to ensure it is zero-terminated, but a size is
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
15 present so strings with null bytes in them can be represented. This
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
16 is an immutable object type.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
17
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
18 There are functions to create new string objects, to test
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
19 an object for string-ness, and to get the
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
20 string value. The latter function returns a null pointer
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
21 if the object is not of the proper type.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
22 There is a variant that takes an explicit size as well as a
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
23 variant that assumes a zero-terminated string. Note that none of the
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
24 functions should be applied to nil objects.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
25 */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
26
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
27 /* Caching the hash (ob_shash) saves recalculation of a string's hash value.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
28 Interning strings (ob_sstate) tries to ensure that only one string
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
29 object with a given value exists, so equality tests can be one pointer
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
30 comparison. This is generally restricted to strings that "look like"
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
31 Python identifiers, although the intern() builtin can be used to force
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
32 interning of any string.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
33 Together, these sped the interpreter by up to 20%. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
34
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
35 typedef struct {
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
36 PyObject_VAR_HEAD
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
37 long ob_shash;
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
38 int ob_sstate;
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
39 char ob_sval[1];
33856
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 29726
diff changeset
40
47578
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
41 /* Invariants:
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
42 * ob_sval contains space for 'ob_size+1' elements.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
43 * ob_sval[ob_size] == 0.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
44 * ob_shash is the hash of the string or -1 if not computed yet.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
45 * ob_sstate != 0 iff the string object is in stringobject.c's
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
46 * 'interned' dictionary; in this case the two references
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
47 * from 'interned' to this object are *not counted* in ob_refcnt.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
48 */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
49 } PyStringObject;
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
50
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
51 #define SSTATE_NOT_INTERNED 0
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
52 #define SSTATE_INTERNED_MORTAL 1
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
53 #define SSTATE_INTERNED_IMMORTAL 2
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
54
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
55 PyAPI_DATA(PyTypeObject) PyBaseString_Type;
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
56 PyAPI_DATA(PyTypeObject) PyString_Type;
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
57
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
58 #define PyString_Check(op) \
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
59 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS)
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
60 #define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type)
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
61
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
62 PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
63 PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
64 PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list)
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
65 Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
66 PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
67 Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
68 PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
69 PyAPI_FUNC(char *) PyString_AsString(PyObject *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
70 PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
71 PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
72 PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
73 PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
74 PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
75 PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
76 PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
77 int, char**, int*);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
78 PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
79 const char *, Py_ssize_t,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
80 const char *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
81
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
82 PyAPI_FUNC(void) PyString_InternInPlace(PyObject **);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
83 PyAPI_FUNC(void) PyString_InternImmortal(PyObject **);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
84 PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
85 PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
86
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
87 /* Use only if you know it's a string */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
88 #define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate)
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
89
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
90 /* Macro, trading safety for speed */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
91 #define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval)
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
92 #define PyString_GET_SIZE(op) Py_SIZE(op)
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
93
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
94 /* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
95 x must be an iterable object. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
96 PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
97
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
98 /* --- Generic Codecs ----------------------------------------------------- */
18129
9d533ae574d2 SF bug 433228: repr(list) woes when len(list) big.
Tim Peters <tim.peters@gmail.com>
parents: 17964
diff changeset
99
47578
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
100 /* Create an object by decoding the encoded string s of the
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
101 given size. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
102
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
103 PyAPI_FUNC(PyObject*) PyString_Decode(
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
104 const char *s, /* encoded string */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
105 Py_ssize_t size, /* size of buffer */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
106 const char *encoding, /* encoding */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
107 const char *errors /* error handling */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
108 );
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
109
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
110 /* Encodes a char buffer of the given size and returns a
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
111 Python object. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
112
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
113 PyAPI_FUNC(PyObject*) PyString_Encode(
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
114 const char *s, /* string char buffer */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
115 Py_ssize_t size, /* number of chars to encode */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
116 const char *encoding, /* encoding */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
117 const char *errors /* error handling */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
118 );
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
119
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
120 /* Encodes a string object and returns the result as Python
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
121 object. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
122
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
123 PyAPI_FUNC(PyObject*) PyString_AsEncodedObject(
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
124 PyObject *str, /* string object */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
125 const char *encoding, /* encoding */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
126 const char *errors /* error handling */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
127 );
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
128
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
129 /* Encodes a string object and returns the result as Python string
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
130 object.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
131
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
132 If the codec returns an Unicode object, the object is converted
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
133 back to a string using the default encoding.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
134
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
135 DEPRECATED - use PyString_AsEncodedObject() instead. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
136
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
137 PyAPI_FUNC(PyObject*) PyString_AsEncodedString(
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
138 PyObject *str, /* string object */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
139 const char *encoding, /* encoding */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
140 const char *errors /* error handling */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
141 );
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
142
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
143 /* Decodes a string object and returns the result as Python
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
144 object. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
145
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
146 PyAPI_FUNC(PyObject*) PyString_AsDecodedObject(
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
147 PyObject *str, /* string object */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
148 const char *encoding, /* encoding */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
149 const char *errors /* error handling */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
150 );
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
151
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
152 /* Decodes a string object and returns the result as Python string
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
153 object.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
154
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
155 If the codec returns an Unicode object, the object is converted
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
156 back to a string using the default encoding.
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
157
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
158 DEPRECATED - use PyString_AsDecodedObject() instead. */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
159
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
160 PyAPI_FUNC(PyObject*) PyString_AsDecodedString(
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
161 PyObject *str, /* string object */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
162 const char *encoding, /* encoding */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
163 const char *errors /* error handling */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
164 );
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
165
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
166 /* Provides access to the internal data buffer and size of a string
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
167 object or the default encoded version of an Unicode object. Passing
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
168 NULL as *len parameter will force the string buffer to be
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
169 0-terminated (passing a string with embedded NULL characters will
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
170 cause an exception). */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
171
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
172 PyAPI_FUNC(int) PyString_AsStringAndSize(
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
173 register PyObject *obj, /* string or Unicode object */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
174 register char **s, /* pointer to buffer variable */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
175 register Py_ssize_t *len /* pointer to length variable or NULL
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
176 (only possible for 0-terminated
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
177 strings) */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
178 );
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
179
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
180 /* Using the current locale, insert the thousands grouping
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
181 into the string pointed to by buffer. For the argument descriptions,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
182 see Objects/stringlib/localeutil.h */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
183
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
184 PyAPI_FUNC(int) _PyString_InsertThousandsGrouping(char *buffer,
47815
752e1abaf15a Modified interface to _Py_[String|Unicode]InsertThousandsGrouping, in anticipation of fixing issue 3140.
Eric Smith <eric@trueblade.com>
parents: 47578
diff changeset
185 Py_ssize_t n_buffer,
752e1abaf15a Modified interface to _Py_[String|Unicode]InsertThousandsGrouping, in anticipation of fixing issue 3140.
Eric Smith <eric@trueblade.com>
parents: 47578
diff changeset
186 Py_ssize_t n_digits,
47578
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
187 Py_ssize_t buf_size,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
188 Py_ssize_t *count,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
189 int append_zero_char);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
190
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
191 /* Format the object based on the format_spec, as defined in PEP 3101
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
192 (Advanced String Formatting). */
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
193 PyAPI_FUNC(PyObject *) _PyBytes_FormatAdvanced(PyObject *obj,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
194 char *format_spec,
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
195 Py_ssize_t format_spec_len);
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
196
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
197 #ifdef __cplusplus
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
198 }
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
199 #endif
acddb00b1de5 swap stringobject.h and bytesobject.h contents to make sense. PyString in
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
200 #endif /* !Py_STRINGOBJECT_H */