diff options
author | Gregory P. Smith <greg@krypto.org> | 2013-03-22 20:49:53 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2013-03-22 20:49:53 (GMT) |
commit | d4296fc19c20525215a26ad639be33e7fb53a898 (patch) | |
tree | d59e62a06903cd137d963276c40e8390294fd1e0 /Doc/faq | |
parent | 5a63fe681363e6fe8ed0f68cf4d617b962d6490e (diff) | |
parent | bcd2aa6d06934fad049aaf107d98e741a7e4440c (diff) | |
download | cpython-d4296fc19c20525215a26ad639be33e7fb53a898.zip cpython-d4296fc19c20525215a26ad639be33e7fb53a898.tar.gz cpython-d4296fc19c20525215a26ad639be33e7fb53a898.tar.bz2 |
cleanup references to PyString_ APIs in the 3.x docs.
Diffstat (limited to 'Doc/faq')
-rw-r--r-- | Doc/faq/extending.rst | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst index fa245c7..4afb510 100644 --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -82,18 +82,20 @@ returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified index. Lists have similar functions, :c:func:`PyListSize` and :c:func:`PyList_GetItem`. -For strings, :c:func:`PyString_Size` returns its length and -:c:func:`PyString_AsString` a pointer to its value. Note that Python strings may -contain null bytes so C's :c:func:`strlen` should not be used. +For bytes, :c:func:`PyBytes_Size` returns its length and +:c:func:`PyBytes_AsStringAndSize` provides a pointer to its value and its +length. Note that Python bytes objects may contain null bytes so C's +:c:func:`strlen` should not be used. To test the type of an object, first make sure it isn't *NULL*, and then use -:c:func:`PyString_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc. +:c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc. There is also a high-level API to Python objects which is provided by the so-called 'abstract' interface -- read ``Include/abstract.h`` for further details. It allows interfacing with any kind of Python sequence using calls -like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc.) as well as -many other useful protocols. +like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc.) as well +as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et. +al.) and mappings in the PyMapping APIs. How do I use Py_BuildValue() to create a tuple of arbitrary length? |