Changeset 391 for python/trunk/Doc/c-api/string.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/c-api/string.rst
r2 r391 18 18 19 19 20 .. c type:: PyStringObject21 22 This subtype of :c type:`PyObject` represents a Python string object.23 24 25 .. c var:: PyTypeObject PyString_Type20 .. c:type:: PyStringObject 21 22 This subtype of :c:type:`PyObject` represents a Python string object. 23 24 25 .. c:var:: PyTypeObject PyString_Type 26 26 27 27 .. index:: single: StringType (in module types) 28 28 29 This instance of :c type:`PyTypeObject` represents the Python string type; it is29 This instance of :c:type:`PyTypeObject` represents the Python string type; it is 30 30 the same object as ``str`` and ``types.StringType`` in the Python layer. . 31 31 32 32 33 .. c function:: int PyString_Check(PyObject *o)33 .. c:function:: int PyString_Check(PyObject *o) 34 34 35 35 Return true if the object *o* is a string object or an instance of a subtype of … … 40 40 41 41 42 .. c function:: int PyString_CheckExact(PyObject *o)42 .. c:function:: int PyString_CheckExact(PyObject *o) 43 43 44 44 Return true if the object *o* is a string object, but not an instance of a … … 48 48 49 49 50 .. c function:: PyObject* PyString_FromString(const char *v)50 .. c:function:: PyObject* PyString_FromString(const char *v) 51 51 52 52 Return a new string object with a copy of the string *v* as value on success, … … 55 55 56 56 57 .. c function:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len)57 .. c:function:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len) 58 58 59 59 Return a new string object with a copy of the string *v* as value and length … … 62 62 63 63 .. versionchanged:: 2.5 64 This function used an :c type:`int` type for *len*. This might require64 This function used an :c:type:`int` type for *len*. This might require 65 65 changes in your code for properly supporting 64-bit systems. 66 66 67 67 68 .. c function:: PyObject* PyString_FromFormat(const char *format, ...)69 70 Take a C :c func:`printf`\ -style *format* string and a variable number of68 .. c:function:: PyObject* PyString_FromFormat(const char *format, ...) 69 70 Take a C :c:func:`printf`\ -style *format* string and a variable number of 71 71 arguments, calculate the size of the resulting Python string and return a string 72 72 with the values formatted into it. The variable arguments must be C types and … … 79 79 .. % because not all compilers support the %z width modifier -- we fake it 80 80 .. % when necessary via interpolating PY_FORMAT_SIZE_T. 81 .. % Similar comments apply to the %ll width modifier and 82 .. % PY_FORMAT_LONG_LONG. 81 83 .. % %u, %lu, %zu should have "new in Python 2.5" blurbs. 82 84 … … 100 102 | :attr:`%lu` | unsigned long | Exactly equivalent to | 101 103 | | | ``printf("%lu")``. | 104 +-------------------+---------------+--------------------------------+ 105 | :attr:`%lld` | long long | Exactly equivalent to | 106 | | | ``printf("%lld")``. | 107 +-------------------+---------------+--------------------------------+ 108 | :attr:`%llu` | unsigned | Exactly equivalent to | 109 | | long long | ``printf("%llu")``. | 102 110 +-------------------+---------------+--------------------------------+ 103 111 | :attr:`%zd` | Py_ssize_t | Exactly equivalent to | … … 128 136 copied as-is to the result string, and any extra arguments discarded. 129 137 130 131 .. cfunction:: PyObject* PyString_FromFormatV(const char *format, va_list vargs) 132 133 Identical to :cfunc:`PyString_FromFormat` except that it takes exactly two 138 .. note:: 139 140 The `"%lld"` and `"%llu"` format specifiers are only available 141 when :const:`HAVE_LONG_LONG` is defined. 142 143 .. versionchanged:: 2.7 144 Support for `"%lld"` and `"%llu"` added. 145 146 147 .. c:function:: PyObject* PyString_FromFormatV(const char *format, va_list vargs) 148 149 Identical to :c:func:`PyString_FromFormat` except that it takes exactly two 134 150 arguments. 135 151 136 152 137 .. c function:: Py_ssize_t PyString_Size(PyObject *string)153 .. c:function:: Py_ssize_t PyString_Size(PyObject *string) 138 154 139 155 Return the length of the string in string object *string*. 140 156 141 157 .. versionchanged:: 2.5 142 This function returned an :c type:`int` type. This might require changes158 This function returned an :c:type:`int` type. This might require changes 143 159 in your code for properly supporting 64-bit systems. 144 160 145 161 146 .. c function:: Py_ssize_t PyString_GET_SIZE(PyObject *string)147 148 Macro form of :c func:`PyString_Size` but without error checking.149 150 .. versionchanged:: 2.5 151 This macro returned an :c type:`int` type. This might require changes in162 .. c:function:: Py_ssize_t PyString_GET_SIZE(PyObject *string) 163 164 Macro form of :c:func:`PyString_Size` but without error checking. 165 166 .. versionchanged:: 2.5 167 This macro returned an :c:type:`int` type. This might require changes in 152 168 your code for properly supporting 64-bit systems. 153 169 154 170 155 .. c function:: char* PyString_AsString(PyObject *string)171 .. c:function:: char* PyString_AsString(PyObject *string) 156 172 157 173 Return a NUL-terminated representation of the contents of *string*. The pointer … … 161 177 *string* is a Unicode object, this function computes the default encoding of 162 178 *string* and operates on that. If *string* is not a string object at all, 163 :c func:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`.164 165 166 .. c function:: char* PyString_AS_STRING(PyObject *string)167 168 Macro form of :c func:`PyString_AsString` but without error checking. Only179 :c:func:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`. 180 181 182 .. c:function:: char* PyString_AS_STRING(PyObject *string) 183 184 Macro form of :c:func:`PyString_AsString` but without error checking. Only 169 185 string objects are supported; no Unicode objects should be passed. 170 186 171 187 172 .. c function:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)188 .. c:function:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length) 173 189 174 190 Return a NUL-terminated representation of the contents of the object *obj* … … 185 201 *string* is a Unicode object, this function computes the default encoding of 186 202 *string* and operates on that. If *string* is not a string object at all, 187 :c func:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`.188 189 .. versionchanged:: 2.5 190 This function used an :c type:`int *` type for *length*. This might203 :c:func:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`. 204 205 .. versionchanged:: 2.5 206 This function used an :c:type:`int *` type for *length*. This might 191 207 require changes in your code for properly supporting 64-bit systems. 192 208 193 209 194 .. c function:: void PyString_Concat(PyObject **string, PyObject *newpart)210 .. c:function:: void PyString_Concat(PyObject **string, PyObject *newpart) 195 211 196 212 Create a new string object in *\*string* containing the contents of *newpart* … … 201 217 202 218 203 .. c function:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart)219 .. c:function:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart) 204 220 205 221 Create a new string object in *\*string* containing the contents of *newpart* … … 207 223 208 224 209 .. c function:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize)225 .. c:function:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize) 210 226 211 227 A way to resize a string object even though it is "immutable". Only use this to … … 220 236 221 237 .. versionchanged:: 2.5 222 This function used an :c type:`int` type for *newsize*. This might238 This function used an :c:type:`int` type for *newsize*. This might 223 239 require changes in your code for properly supporting 64-bit systems. 224 240 225 .. c function:: PyObject* PyString_Format(PyObject *format, PyObject *args)241 .. c:function:: PyObject* PyString_Format(PyObject *format, PyObject *args) 226 242 227 243 Return a new string object from *format* and *args*. Analogous to ``format % 228 args``. The *args* argument must be a tuple .229 230 231 .. c function:: void PyString_InternInPlace(PyObject **string)244 args``. The *args* argument must be a tuple or dict. 245 246 247 .. c:function:: void PyString_InternInPlace(PyObject **string) 232 248 233 249 Intern the argument *\*string* in place. The argument must be the address of a … … 246 262 247 263 248 .. c function:: PyObject* PyString_InternFromString(const char *v)249 250 A combination of :c func:`PyString_FromString` and251 :c func:`PyString_InternInPlace`, returning either a new string object that has264 .. c:function:: PyObject* PyString_InternFromString(const char *v) 265 266 A combination of :c:func:`PyString_FromString` and 267 :c:func:`PyString_InternInPlace`, returning either a new string object that has 252 268 been interned, or a new ("owned") reference to an earlier interned string object 253 269 with the same value. … … 258 274 259 275 260 .. c function:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)276 .. c:function:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) 261 277 262 278 Create an object by decoding *size* bytes of the encoded buffer *s* using the … … 271 287 272 288 .. versionchanged:: 2.5 273 This function used an :c type:`int` type for *size*. This might require289 This function used an :c:type:`int` type for *size*. This might require 274 290 changes in your code for properly supporting 64-bit systems. 275 291 276 292 277 .. c function:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors)293 .. c:function:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors) 278 294 279 295 Decode a string object by passing it to the codec registered for *encoding* and … … 288 304 289 305 290 .. c function:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)291 292 Encode the :c type:`char` buffer of the given size by passing it to the codec306 .. c:function:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) 307 308 Encode the :c:type:`char` buffer of the given size by passing it to the codec 293 309 registered for *encoding* and return a Python object. *encoding* and *errors* 294 310 have the same meaning as the parameters of the same name in the string … … 301 317 302 318 .. versionchanged:: 2.5 303 This function used an :c type:`int` type for *size*. This might require319 This function used an :c:type:`int` type for *size*. This might require 304 320 changes in your code for properly supporting 64-bit systems. 305 321 306 322 307 .. c function:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors)323 .. c:function:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors) 308 324 309 325 Encode a string object using the codec registered for *encoding* and return the
Note:
See TracChangeset
for help on using the changeset viewer.